mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 16:41:25 +00:00
usb: core: Copy parameter string correctly and remove superfluous null check
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: 027bd6cafd
("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
73c6d3b284
commit
a030501499
1 changed files with 7 additions and 2 deletions
|
@ -31,10 +31,15 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
|
||||||
u16 vid, pid;
|
u16 vid, pid;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = param_set_copystring(val, kp);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
mutex_lock(&quirk_mutex);
|
mutex_lock(&quirk_mutex);
|
||||||
|
|
||||||
if (!val || !*val) {
|
if (!*val) {
|
||||||
quirk_count = 0;
|
quirk_count = 0;
|
||||||
kfree(quirk_list);
|
kfree(quirk_list);
|
||||||
quirk_list = NULL;
|
quirk_list = NULL;
|
||||||
|
@ -133,7 +138,7 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
|
||||||
unlock:
|
unlock:
|
||||||
mutex_unlock(&quirk_mutex);
|
mutex_unlock(&quirk_mutex);
|
||||||
|
|
||||||
return param_set_copystring(val, kp);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct kernel_param_ops quirks_param_ops = {
|
static const struct kernel_param_ops quirks_param_ops = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue