Hi,
[This fix is not very good for the global variable, any comments are
welcome.]
The thinkpad_acpi module_init fail out entrace is not very properly. if
failing before register driver or before create sysfs file, the
module_exit will try to remove nonexist sysfs files, the kernel will
oops.
Signed-off-by: Dave Young <[email protected]>
---
drivers/misc/thinkpad_acpi.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff -upr linux/drivers/misc/thinkpad_acpi.c linux.new/drivers/misc/thinkpad_acpi.c
--- linux/drivers/misc/thinkpad_acpi.c 2007-08-08 16:28:19.000000000 +0000
+++ linux.new/drivers/misc/thinkpad_acpi.c 2007-08-08 16:35:11.000000000 +0000
@@ -91,6 +91,8 @@ MODULE_LICENSE("GPL");
/* Please remove this in year 2009 */
MODULE_ALIAS("ibm_acpi");
+static int sysfs_ret = 1;
+static int driver_ret = 1;
/*
* DMI matching for module autoloading
@@ -4662,14 +4664,14 @@ static int __init thinkpad_acpi_module_i
}
proc_dir->owner = THIS_MODULE;
- ret = platform_driver_register(&tpacpi_pdriver);
- if (ret) {
+ driver_ret = platform_driver_register(&tpacpi_pdriver);
+ if (driver_ret) {
printk(IBM_ERR "unable to register platform driver\n");
thinkpad_acpi_module_exit();
return ret;
}
- ret = tpacpi_create_driver_attributes(&tpacpi_pdriver.driver);
- if (ret) {
+ sysfs_ret = tpacpi_create_driver_attributes(&tpacpi_pdriver.driver);
+ if (sysfs_ret) {
printk(IBM_ERR "unable to create sysfs driver attributes\n");
thinkpad_acpi_module_exit();
return ret;
@@ -4756,8 +4758,13 @@ static void thinkpad_acpi_module_exit(vo
if (tpacpi_pdev)
platform_device_unregister(tpacpi_pdev);
- tpacpi_remove_driver_attributes(&tpacpi_pdriver.driver);
- platform_driver_unregister(&tpacpi_pdriver);
+ if(!sysfs_ret){
+ tpacpi_remove_driver_attributes(&tpacpi_pdriver.driver);
+ }
+
+ if(!driver_ret){
+ platform_driver_unregister(&tpacpi_pdriver);
+ }
if (proc_dir)
remove_proc_entry(IBM_PROC_DIR, acpi_root_dir);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]