aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2007-07-27 16:04:40 -0400
committerLen Brown <len.brown@intel.com>2007-08-03 15:32:58 -0400
commitac36393de6034be7266264a435360e7628849005 (patch)
treee530b57c254536aac1c71602552bbde0e71cffe3 /drivers/misc
parent7a883eaf62f4b943ebec738ce3b0796c67ef5d32 (diff)
ACPI: thinkpad-acpi: fix the module init failure path
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>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/thinkpad_acpi.c10
-rw-r--r--drivers/misc/thinkpad_acpi.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index fa80f355e522..f6cd34a3dbac 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -4668,12 +4668,15 @@ static int __init thinkpad_acpi_module_init(void)
4668 thinkpad_acpi_module_exit(); 4668 thinkpad_acpi_module_exit();
4669 return ret; 4669 return ret;
4670 } 4670 }
4671 tp_features.platform_drv_registered = 1;
4672
4671 ret = tpacpi_create_driver_attributes(&tpacpi_pdriver.driver); 4673 ret = tpacpi_create_driver_attributes(&tpacpi_pdriver.driver);
4672 if (ret) { 4674 if (ret) {
4673 printk(IBM_ERR "unable to create sysfs driver attributes\n"); 4675 printk(IBM_ERR "unable to create sysfs driver attributes\n");
4674 thinkpad_acpi_module_exit(); 4676 thinkpad_acpi_module_exit();
4675 return ret; 4677 return ret;
4676 } 4678 }
4679 tp_features.platform_drv_attrs_registered = 1;
4677 4680
4678 4681
4679 /* Device initialization */ 4682 /* Device initialization */
@@ -4756,8 +4759,11 @@ static void thinkpad_acpi_module_exit(void)
4756 if (tpacpi_pdev) 4759 if (tpacpi_pdev)
4757 platform_device_unregister(tpacpi_pdev); 4760 platform_device_unregister(tpacpi_pdev);
4758 4761
4759 tpacpi_remove_driver_attributes(&tpacpi_pdriver.driver); 4762 if (tp_features.platform_drv_attrs_registered)
4760 platform_driver_unregister(&tpacpi_pdriver); 4763 tpacpi_remove_driver_attributes(&tpacpi_pdriver.driver);
4764
4765 if (tp_features.platform_drv_registered)
4766 platform_driver_unregister(&tpacpi_pdriver);
4761 4767
4762 if (proc_dir) 4768 if (proc_dir)
4763 remove_proc_entry(IBM_PROC_DIR, acpi_root_dir); 4769 remove_proc_entry(IBM_PROC_DIR, acpi_root_dir);
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 88af089d6494..eee8809a50d9 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -246,6 +246,8 @@ static struct {
246 u16 wan:1; 246 u16 wan:1;
247 u16 fan_ctrl_status_undef:1; 247 u16 fan_ctrl_status_undef:1;
248 u16 input_device_registered:1; 248 u16 input_device_registered:1;
249 u16 platform_drv_registered:1;
250 u16 platform_drv_attrs_registered:1;
249} tp_features; 251} tp_features;
250 252
251struct thinkpad_id_data { 253struct thinkpad_id_data {