aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2010-06-10 04:06:40 -0400
committerMatthew Garrett <mjg@redhat.com>2010-08-03 09:48:47 -0400
commitdfec5c48cdfdcb08d73d24cbf277de543ef864ae (patch)
tree49286224b8cc935b9b2f914e185960f69a34f5c8 /drivers/platform
parent35f2915c3bd0cd6950bdd9d461de565e8feae852 (diff)
hp-wmi: add error handling for hp_wmi_init
Current implementation in hp_wmi_init does not check any error and always return success. This patch properly handles recource reclaim and return err in error path. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/hp-wmi.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index d81f4cf70afc..9498bdd53618 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -715,23 +715,42 @@ static int __init hp_wmi_init(void)
715 if (wmi_has_guid(HPWMI_EVENT_GUID)) { 715 if (wmi_has_guid(HPWMI_EVENT_GUID)) {
716 err = wmi_install_notify_handler(HPWMI_EVENT_GUID, 716 err = wmi_install_notify_handler(HPWMI_EVENT_GUID,
717 hp_wmi_notify, NULL); 717 hp_wmi_notify, NULL);
718 if (ACPI_SUCCESS(err)) 718 if (ACPI_FAILURE(err))
719 hp_wmi_input_setup(); 719 return -EINVAL;
720 err = hp_wmi_input_setup();
721 if (err) {
722 wmi_remove_notify_handler(HPWMI_EVENT_GUID);
723 return err;
724 }
720 } 725 }
721 726
722 if (wmi_has_guid(HPWMI_BIOS_GUID)) { 727 if (wmi_has_guid(HPWMI_BIOS_GUID)) {
723 err = platform_driver_register(&hp_wmi_driver); 728 err = platform_driver_register(&hp_wmi_driver);
724 if (err) 729 if (err)
725 return 0; 730 goto err_driver_reg;
726 hp_wmi_platform_dev = platform_device_alloc("hp-wmi", -1); 731 hp_wmi_platform_dev = platform_device_alloc("hp-wmi", -1);
727 if (!hp_wmi_platform_dev) { 732 if (!hp_wmi_platform_dev) {
728 platform_driver_unregister(&hp_wmi_driver); 733 err = -ENOMEM;
729 return 0; 734 goto err_device_alloc;
730 } 735 }
731 platform_device_add(hp_wmi_platform_dev); 736 err = platform_device_add(hp_wmi_platform_dev);
737 if (err)
738 goto err_device_add;
732 } 739 }
733 740
734 return 0; 741 return 0;
742
743err_device_add:
744 platform_device_put(hp_wmi_platform_dev);
745err_device_alloc:
746 platform_driver_unregister(&hp_wmi_driver);
747err_driver_reg:
748 if (wmi_has_guid(HPWMI_EVENT_GUID)) {
749 input_unregister_device(hp_wmi_input_dev);
750 wmi_remove_notify_handler(HPWMI_EVENT_GUID);
751 }
752
753 return err;
735} 754}
736 755
737static void __exit hp_wmi_exit(void) 756static void __exit hp_wmi_exit(void)