diff options
-rw-r--r-- | drivers/platform/x86/acerhdf.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index 4ce28d901b9a..60f9cfcac93f 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c | |||
@@ -615,17 +615,26 @@ static int acerhdf_register_platform(void) | |||
615 | return err; | 615 | return err; |
616 | 616 | ||
617 | acerhdf_dev = platform_device_alloc("acerhdf", -1); | 617 | acerhdf_dev = platform_device_alloc("acerhdf", -1); |
618 | platform_device_add(acerhdf_dev); | 618 | if (!acerhdf_dev) { |
619 | err = -ENOMEM; | ||
620 | goto err_device_alloc; | ||
621 | } | ||
622 | err = platform_device_add(acerhdf_dev); | ||
623 | if (err) | ||
624 | goto err_device_add; | ||
619 | 625 | ||
620 | return 0; | 626 | return 0; |
627 | |||
628 | err_device_add: | ||
629 | platform_device_put(acerhdf_dev); | ||
630 | err_device_alloc: | ||
631 | platform_driver_unregister(&acerhdf_driver); | ||
632 | return err; | ||
621 | } | 633 | } |
622 | 634 | ||
623 | static void acerhdf_unregister_platform(void) | 635 | static void acerhdf_unregister_platform(void) |
624 | { | 636 | { |
625 | if (!acerhdf_dev) | 637 | platform_device_unregister(acerhdf_dev); |
626 | return; | ||
627 | |||
628 | platform_device_del(acerhdf_dev); | ||
629 | platform_driver_unregister(&acerhdf_driver); | 638 | platform_driver_unregister(&acerhdf_driver); |
630 | } | 639 | } |
631 | 640 | ||
@@ -669,7 +678,7 @@ static int __init acerhdf_init(void) | |||
669 | 678 | ||
670 | err = acerhdf_register_platform(); | 679 | err = acerhdf_register_platform(); |
671 | if (err) | 680 | if (err) |
672 | goto err_unreg; | 681 | goto out_err; |
673 | 682 | ||
674 | err = acerhdf_register_thermal(); | 683 | err = acerhdf_register_thermal(); |
675 | if (err) | 684 | if (err) |
@@ -682,7 +691,7 @@ err_unreg: | |||
682 | acerhdf_unregister_platform(); | 691 | acerhdf_unregister_platform(); |
683 | 692 | ||
684 | out_err: | 693 | out_err: |
685 | return -ENODEV; | 694 | return err; |
686 | } | 695 | } |
687 | 696 | ||
688 | static void __exit acerhdf_exit(void) | 697 | static void __exit acerhdf_exit(void) |