Browse Source

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.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Dan Carpenter 9 years ago
parent
commit
6edac6fde5
1 changed files with 2 additions and 3 deletions
  1. 2 3
      drivers/hid/hidraw.c

+ 2 - 3
drivers/hid/hidraw.c

@@ -587,14 +587,13 @@ int __init hidraw_init(void)
 
 
 	result = alloc_chrdev_region(&dev_id, HIDRAW_FIRST_MINOR,
 	result = alloc_chrdev_region(&dev_id, HIDRAW_FIRST_MINOR,
 			HIDRAW_MAX_DEVICES, "hidraw");
 			HIDRAW_MAX_DEVICES, "hidraw");
-
-	hidraw_major = MAJOR(dev_id);
-
 	if (result < 0) {
 	if (result < 0) {
 		pr_warn("can't get major number\n");
 		pr_warn("can't get major number\n");
 		goto out;
 		goto out;
 	}
 	}
 
 
+	hidraw_major = MAJOR(dev_id);
+
 	hidraw_class = class_create(THIS_MODULE, "hidraw");
 	hidraw_class = class_create(THIS_MODULE, "hidraw");
 	if (IS_ERR(hidraw_class)) {
 	if (IS_ERR(hidraw_class)) {
 		result = PTR_ERR(hidraw_class);
 		result = PTR_ERR(hidraw_class);