Commit 1c79632b authored by Axel Lin's avatar Axel Lin Committed by Matthew Garrett

acer-wmi: fix resource reclaim in acer_wmi_init error path

This patch fixes the resource reclaim in acer_wmi_init error path.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
parent e9ec7f35
...@@ -1327,22 +1327,31 @@ static int __init acer_wmi_init(void) ...@@ -1327,22 +1327,31 @@ static int __init acer_wmi_init(void)
"generic video driver\n"); "generic video driver\n");
} }
if (platform_driver_register(&acer_platform_driver)) { err = platform_driver_register(&acer_platform_driver);
if (err) {
printk(ACER_ERR "Unable to register platform driver.\n"); printk(ACER_ERR "Unable to register platform driver.\n");
goto error_platform_register; goto error_platform_register;
} }
acer_platform_device = platform_device_alloc("acer-wmi", -1); acer_platform_device = platform_device_alloc("acer-wmi", -1);
platform_device_add(acer_platform_device); if (!acer_platform_device) {
err = -ENOMEM;
goto error_device_alloc;
}
err = platform_device_add(acer_platform_device);
if (err)
goto error_device_add;
err = create_sysfs(); err = create_sysfs();
if (err) if (err)
return err; goto error_create_sys;
if (wmi_has_guid(WMID_GUID2)) { if (wmi_has_guid(WMID_GUID2)) {
interface->debug.wmid_devices = get_wmid_devices(); interface->debug.wmid_devices = get_wmid_devices();
err = create_debugfs(); err = create_debugfs();
if (err) if (err)
return err; goto error_create_debugfs;
} }
/* Override any initial settings with values from the commandline */ /* Override any initial settings with values from the commandline */
...@@ -1350,8 +1359,16 @@ static int __init acer_wmi_init(void) ...@@ -1350,8 +1359,16 @@ static int __init acer_wmi_init(void)
return 0; return 0;
error_create_debugfs:
remove_sysfs(acer_platform_device);
error_create_sys:
platform_device_del(acer_platform_device);
error_device_add:
platform_device_put(acer_platform_device);
error_device_alloc:
platform_driver_unregister(&acer_platform_driver);
error_platform_register: error_platform_register:
return -ENODEV; return err;
} }
static void __exit acer_wmi_exit(void) static void __exit acer_wmi_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment