diff options
author | Vasiliy Kulikov <segoon@openwall.com> | 2011-01-17 05:08:45 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-01-17 07:20:43 -0500 |
commit | dacfecdbf3a0a5072984ff8b3c224a48c8461008 (patch) | |
tree | bd5044426d722147161f3d3e725f76bec4849556 /drivers | |
parent | 581548db3b3c0f6e25b500329eb02e3c72e7acbe (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hid/hid-roccat-koneplus.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c index 1608c8d1efd6..591a97cf6b65 100644 --- a/drivers/hid/hid-roccat-koneplus.c +++ b/drivers/hid/hid-roccat-koneplus.c | |||
@@ -220,6 +220,8 @@ static int koneplus_get_startup_profile(struct usb_device *usb_dev) | |||
220 | int retval; | 220 | int retval; |
221 | 221 | ||
222 | buf = kmalloc(sizeof(struct koneplus_startup_profile), GFP_KERNEL); | 222 | buf = kmalloc(sizeof(struct koneplus_startup_profile), GFP_KERNEL); |
223 | if (buf == NULL) | ||
224 | return -ENOMEM; | ||
223 | 225 | ||
224 | retval = koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE, | 226 | retval = koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE, |
225 | buf, sizeof(struct koneplus_startup_profile)); | 227 | buf, sizeof(struct koneplus_startup_profile)); |
@@ -614,6 +616,8 @@ static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, | |||
614 | mutex_init(&koneplus->koneplus_lock); | 616 | mutex_init(&koneplus->koneplus_lock); |
615 | 617 | ||
616 | koneplus->startup_profile = koneplus_get_startup_profile(usb_dev); | 618 | koneplus->startup_profile = koneplus_get_startup_profile(usb_dev); |
619 | if (koneplus->startup_profile < 0) | ||
620 | return koneplus->startup_profile; | ||
617 | 621 | ||
618 | msleep(wait); | 622 | msleep(wait); |
619 | retval = koneplus_get_info(usb_dev, &koneplus->info); | 623 | retval = koneplus_get_info(usb_dev, &koneplus->info); |