HID: hid-roccat-koneplus: potential NULL dereference
kmalloc() may fail, if so return -ENOMEM. Also koneplus_init_koneplus_device_struct() should check return code of koneplus_get_startup_profile() and propagate its return code. Signed-off-by: Vasiliy Kulikov <segoon@openwall.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
581548db3b
commit
dacfecdbf3
@ -220,6 +220,8 @@ static int koneplus_get_startup_profile(struct usb_device *usb_dev)
|
|||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
buf = kmalloc(sizeof(struct koneplus_startup_profile), GFP_KERNEL);
|
buf = kmalloc(sizeof(struct koneplus_startup_profile), GFP_KERNEL);
|
||||||
|
if (buf == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
retval = koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE,
|
retval = koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE,
|
||||||
buf, sizeof(struct koneplus_startup_profile));
|
buf, sizeof(struct koneplus_startup_profile));
|
||||||
@ -614,6 +616,8 @@ static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev,
|
|||||||
mutex_init(&koneplus->koneplus_lock);
|
mutex_init(&koneplus->koneplus_lock);
|
||||||
|
|
||||||
koneplus->startup_profile = koneplus_get_startup_profile(usb_dev);
|
koneplus->startup_profile = koneplus_get_startup_profile(usb_dev);
|
||||||
|
if (koneplus->startup_profile < 0)
|
||||||
|
return koneplus->startup_profile;
|
||||||
|
|
||||||
msleep(wait);
|
msleep(wait);
|
||||||
retval = koneplus_get_info(usb_dev, &koneplus->info);
|
retval = koneplus_get_info(usb_dev, &koneplus->info);
|
||||||
|
Loading…
Reference in New Issue
Block a user