diff options
author | Michael Rissi <michael.rissi@gmail.com> | 2013-06-14 11:16:37 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-06-18 05:00:36 -0400 |
commit | a0be10c2e0c822c0fdd6b207696012060147f84b (patch) | |
tree | 9d374c7706ef5b94cc65894e7cea9b280d3592c7 /drivers/hid | |
parent | a4a23f6d68ad2c86ee8df6a6f89c9d315c0a761c (diff) |
HID: roccat: check cdev_add return value
Return value of cdev_add in hid_roccat.c init was not checked.
Signed-off-by: Michael Rissi <michael.rissi@dectris.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-roccat.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c index b59b3df9ca95..65c4ccfcbd29 100644 --- a/drivers/hid/hid-roccat.c +++ b/drivers/hid/hid-roccat.c | |||
@@ -366,7 +366,7 @@ void roccat_disconnect(int minor) | |||
366 | mutex_lock(&devices_lock); | 366 | mutex_lock(&devices_lock); |
367 | devices[minor] = NULL; | 367 | devices[minor] = NULL; |
368 | mutex_unlock(&devices_lock); | 368 | mutex_unlock(&devices_lock); |
369 | 369 | ||
370 | if (device->open) { | 370 | if (device->open) { |
371 | hid_hw_close(device->hid); | 371 | hid_hw_close(device->hid); |
372 | wake_up_interruptible(&device->wait); | 372 | wake_up_interruptible(&device->wait); |
@@ -426,13 +426,23 @@ static int __init roccat_init(void) | |||
426 | 426 | ||
427 | if (retval < 0) { | 427 | if (retval < 0) { |
428 | pr_warn("can't get major number\n"); | 428 | pr_warn("can't get major number\n"); |
429 | return retval; | 429 | goto error; |
430 | } | 430 | } |
431 | 431 | ||
432 | cdev_init(&roccat_cdev, &roccat_ops); | 432 | cdev_init(&roccat_cdev, &roccat_ops); |
433 | cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES); | 433 | retval = cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES); |
434 | 434 | ||
435 | if (retval < 0) { | ||
436 | pr_warn("cannot add cdev\n"); | ||
437 | goto cleanup_alloc_chrdev_region; | ||
438 | } | ||
435 | return 0; | 439 | return 0; |
440 | |||
441 | |||
442 | cleanup_alloc_chrdev_region: | ||
443 | unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES); | ||
444 | error: | ||
445 | return retval; | ||
436 | } | 446 | } |
437 | 447 | ||
438 | static void __exit roccat_exit(void) | 448 | static void __exit roccat_exit(void) |