Skip to content

Commit

Permalink
ACPI: thinkpad-acpi: fix the module init failure path
Browse files Browse the repository at this point in the history
Thomas Renninger reports that if one tries to load thinkpad-acpi in a
non-thinkpad, one gets:

Call Trace:
 [<ffffffff802fa57d>] kref_get+0x2f/0x36
 [<ffffffff802f97f7>] kobject_get+0x12/0x17
 [<ffffffff8036dfd7>] get_driver+0x14/0x1a
 [<ffffffff8036dfee>] driver_remove_file+0x11/0x32
 [<ffffffff8823b9be>] :thinkpad_acpi:thinkpad_acpi_module_exit+0xa8/0xfc
 [<ffffffff8824b8a0>] :thinkpad_acpi:thinkpad_acpi_module_init+0x74a/0x776
 [<ffffffff8024f968>] __link_module+0x0/0x25
 [<ffffffff80252269>] sys_init_module+0x162c/0x178f
 [<ffffffff8020bc2e>] system_call+0x7e/0x83

So, track if the platform driver and its driver attributes were registered,
and only deallocate them in that case.

This patch is based on Thomas Renninger's patch for the issue.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Acked-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Henrique de Moraes Holschuh authored and Len Brown committed Aug 3, 2007
1 parent 7a883ea commit ac36393
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/misc/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4668,12 +4668,15 @@ static int __init thinkpad_acpi_module_init(void)
thinkpad_acpi_module_exit();
return ret;
}
tp_features.platform_drv_registered = 1;

ret = tpacpi_create_driver_attributes(&tpacpi_pdriver.driver);
if (ret) {
printk(IBM_ERR "unable to create sysfs driver attributes\n");
thinkpad_acpi_module_exit();
return ret;
}
tp_features.platform_drv_attrs_registered = 1;


/* Device initialization */
Expand Down Expand Up @@ -4756,8 +4759,11 @@ static void thinkpad_acpi_module_exit(void)
if (tpacpi_pdev)
platform_device_unregister(tpacpi_pdev);

tpacpi_remove_driver_attributes(&tpacpi_pdriver.driver);
platform_driver_unregister(&tpacpi_pdriver);
if (tp_features.platform_drv_attrs_registered)
tpacpi_remove_driver_attributes(&tpacpi_pdriver.driver);

if (tp_features.platform_drv_registered)
platform_driver_unregister(&tpacpi_pdriver);

if (proc_dir)
remove_proc_entry(IBM_PROC_DIR, acpi_root_dir);
Expand Down
2 changes: 2 additions & 0 deletions drivers/misc/thinkpad_acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ static struct {
u16 wan:1;
u16 fan_ctrl_status_undef:1;
u16 input_device_registered:1;
u16 platform_drv_registered:1;
u16 platform_drv_attrs_registered:1;
} tp_features;

struct thinkpad_id_data {
Expand Down

0 comments on commit ac36393

Please sign in to comment.