* [PATCH] HID: roccat: check cdev_add return values
@ 2013-06-14 15:16 Michael Rissi
2013-06-18 9:01 ` Jiri Kosina
0 siblings, 1 reply; 2+ messages in thread
From: Michael Rissi @ 2013-06-14 15:16 UTC (permalink / raw)
To: jkosina, linux-input, linux-kernel; +Cc: Michael Rissi
Return value of cdev_add in hid_roccat.c init was not checked.
Signed-off-by: Michael Rissi <michael.rissi@dectris.com>
---
drivers/hid/hid-roccat.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
index b59b3df..65c4ccfc 100644
--- a/drivers/hid/hid-roccat.c
+++ b/drivers/hid/hid-roccat.c
@@ -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);
@@ -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)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] HID: roccat: check cdev_add return values
2013-06-14 15:16 [PATCH] HID: roccat: check cdev_add return values Michael Rissi
@ 2013-06-18 9:01 ` Jiri Kosina
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2013-06-18 9:01 UTC (permalink / raw)
To: Michael Rissi; +Cc: linux-input, linux-kernel, Michael Rissi
On Fri, 14 Jun 2013, Michael Rissi wrote:
> Return value of cdev_add in hid_roccat.c init was not checked.
>
> Signed-off-by: Michael Rissi <michael.rissi@dectris.com>
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-18 9:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-14 15:16 [PATCH] HID: roccat: check cdev_add return values Michael Rissi
2013-06-18 9:01 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).