Skip to content

Commit

Permalink
HID: roccat: check cdev_add return value
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Rissi authored and Jiri Kosina committed Jun 18, 2013
1 parent a4a23f6 commit a0be10c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions drivers/hid/hid-roccat.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void roccat_disconnect(int minor)
mutex_lock(&devices_lock);
devices[minor] = NULL;
mutex_unlock(&devices_lock);

if (device->open) {
hid_hw_close(device->hid);
wake_up_interruptible(&device->wait);
Expand Down Expand Up @@ -426,13 +426,23 @@ static int __init roccat_init(void)

if (retval < 0) {
pr_warn("can't get major number\n");
return retval;
goto error;
}

cdev_init(&roccat_cdev, &roccat_ops);
cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES);
retval = cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES);

if (retval < 0) {
pr_warn("cannot add cdev\n");
goto cleanup_alloc_chrdev_region;
}
return 0;


cleanup_alloc_chrdev_region:
unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES);
error:
return retval;
}

static void __exit roccat_exit(void)
Expand Down

0 comments on commit a0be10c

Please sign in to comment.