diff options
| -rw-r--r-- | drivers/hid/hidraw.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 3b6f7bf5a77e..7c47fc3f7b2b 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
| @@ -559,21 +559,28 @@ int __init hidraw_init(void) | |||
| 559 | 559 | ||
| 560 | if (result < 0) { | 560 | if (result < 0) { |
| 561 | pr_warn("can't get major number\n"); | 561 | pr_warn("can't get major number\n"); |
| 562 | result = 0; | ||
| 563 | goto out; | 562 | goto out; |
| 564 | } | 563 | } |
| 565 | 564 | ||
| 566 | hidraw_class = class_create(THIS_MODULE, "hidraw"); | 565 | hidraw_class = class_create(THIS_MODULE, "hidraw"); |
| 567 | if (IS_ERR(hidraw_class)) { | 566 | if (IS_ERR(hidraw_class)) { |
| 568 | result = PTR_ERR(hidraw_class); | 567 | result = PTR_ERR(hidraw_class); |
| 569 | unregister_chrdev(hidraw_major, "hidraw"); | 568 | goto error_cdev; |
| 570 | goto out; | ||
| 571 | } | 569 | } |
| 572 | 570 | ||
| 573 | cdev_init(&hidraw_cdev, &hidraw_ops); | 571 | cdev_init(&hidraw_cdev, &hidraw_ops); |
| 574 | cdev_add(&hidraw_cdev, dev_id, HIDRAW_MAX_DEVICES); | 572 | result = cdev_add(&hidraw_cdev, dev_id, HIDRAW_MAX_DEVICES); |
| 573 | if (result < 0) | ||
| 574 | goto error_class; | ||
| 575 | |||
| 575 | out: | 576 | out: |
| 576 | return result; | 577 | return result; |
| 578 | |||
| 579 | error_class: | ||
| 580 | class_destroy(hidraw_class); | ||
| 581 | error_cdev: | ||
| 582 | unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES); | ||
| 583 | goto out; | ||
| 577 | } | 584 | } |
| 578 | 585 | ||
| 579 | void hidraw_exit(void) | 586 | void hidraw_exit(void) |
