linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] HID: hidraw: silence an uninitialized variable warning
@ 2016-04-02  4:45 Dan Carpenter
  2016-04-04  7:50 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-04-02  4:45 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, kernel-janitors

My static checker complains that "devid" can be uninitialized if
alloc_chrdev_region() fails.  Fix this by moving the error hanling
forward a couple lines.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index b9a76e3..f0e2757 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -582,14 +582,13 @@ int __init hidraw_init(void)
 
 	result = alloc_chrdev_region(&dev_id, HIDRAW_FIRST_MINOR,
 			HIDRAW_MAX_DEVICES, "hidraw");
-
-	hidraw_major = MAJOR(dev_id);
-
 	if (result < 0) {
 		pr_warn("can't get major number\n");
 		goto out;
 	}
 
+	hidraw_major = MAJOR(dev_id);
+
 	hidraw_class = class_create(THIS_MODULE, "hidraw");
 	if (IS_ERR(hidraw_class)) {
 		result = PTR_ERR(hidraw_class);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-04  7:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-02  4:45 [patch] HID: hidraw: silence an uninitialized variable warning Dan Carpenter
2016-04-04  7:50 ` 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).