Skip to contentSkip to conversation

HID: hidraw: silence an uninitialized variable warning

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 2, 2016 – Apr 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: hidraw: silence an uninitialized variable warning

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.

drivers/hid/hidraw.c +2 -3
index b9a76e3..f0e2757 100644
@@ -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);
maintainer Applied
#1 lore raw
Quoted 5 lines · Dan Carpenter

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.

Applied, thanks Dan.

Signature · 2 lines
Jiri Kosina
SUSE Labs