* [PATCH 1/2] usb: core: Copy parameter string correctly and remove superfluous null check
@ 2018-03-23 19:26 Kai-Heng Feng
2018-03-23 19:26 ` [PATCH 2/2] usb: core: Add USB_QUIRK_DELAY_CTRL_MSG to usbcore quirks Kai-Heng Feng
0 siblings, 1 reply; 2+ messages in thread
From: Kai-Heng Feng @ 2018-03-23 19:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, linux-usb, Kai-Heng Feng, Dan Carpenter
strsep() slices string, so the string gets copied by
param_set_copystring() at the end of quirks_param_set() is not the
original value.
Fix that by calling param_set_copystring() earlier.
The null check for val is unnecessary, the caller of quirks_param_set()
does not pass null string.
Remove the superfluous null check. This is found by Smatch.
Fixes: 027bd6cafd9a ("usb: core: Add "quirks" parameter for usbcore")
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
drivers/usb/core/quirks.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 6fb8d5433268..29e5f32b38df 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -31,10 +31,15 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
u16 vid, pid;
u32 flags;
size_t i;
+ int err;
+
+ err = param_set_copystring(val, kp);
+ if (err)
+ return err;
mutex_lock(&quirk_mutex);
- if (!val || !*val) {
+ if (!*val) {
quirk_count = 0;
kfree(quirk_list);
quirk_list = NULL;
@@ -133,7 +138,7 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
unlock:
mutex_unlock(&quirk_mutex);
- return param_set_copystring(val, kp);
+ return 0;
}
static const struct kernel_param_ops quirks_param_ops = {
--
2.15.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] usb: core: Add USB_QUIRK_DELAY_CTRL_MSG to usbcore quirks
2018-03-23 19:26 [PATCH 1/2] usb: core: Copy parameter string correctly and remove superfluous null check Kai-Heng Feng
@ 2018-03-23 19:26 ` Kai-Heng Feng
0 siblings, 0 replies; 2+ messages in thread
From: Kai-Heng Feng @ 2018-03-23 19:26 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, linux-usb, Kai-Heng Feng
There's a new quirk, USB_QUIRK_DELAY_CTRL_MSG. Add it to usbcore quirks
for completeness.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
Documentation/admin-guide/kernel-parameters.txt | 4 +++-
drivers/usb/core/quirks.c | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 61ab660f7fdc..a0b4377cb8da 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4454,7 +4454,9 @@
calculation);
m = USB_QUIRK_DISCONNECT_SUSPEND (Device needs
to be disconnected before suspend to
- prevent spurious wakeup)
+ prevent spurious wakeup);
+ n = USB_QUIRK_DELAY_CTRL_MSG (Device needs a
+ pause after every control message);
Example: quirks=0781:5580:bk,0a5c:5834:gij
usbhid.mousepoll=
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 29e5f32b38df..920f48a49a87 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -124,6 +124,9 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
case 'm':
flags |= USB_QUIRK_DISCONNECT_SUSPEND;
break;
+ case 'n':
+ flags |= USB_QUIRK_DELAY_CTRL_MSG;
+ break;
/* Ignore unrecognized flag characters */
}
}
--
2.15.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-23 19:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-23 19:26 [PATCH 1/2] usb: core: Copy parameter string correctly and remove superfluous null check Kai-Heng Feng
2018-03-23 19:26 ` [PATCH 2/2] usb: core: Add USB_QUIRK_DELAY_CTRL_MSG to usbcore quirks Kai-Heng Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).