From: Len Brown <len.brown@intel.com>
To: linux-acpi@vger.kernel.org
Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
Len Brown <len.brown@intel.com>
Subject: [PATCH 05/12] ACPI: thinkpad-acpi: fix the module init failure path
Date: Fri, 3 Aug 2007 18:33:38 -0400 [thread overview]
Message-ID: <11861804303949-git-send-email-len.brown@intel.com> (raw)
Message-ID: <ac36393de6034be7266264a435360e7628849005.1186180370.git.len.brown@intel.com> (raw)
In-Reply-To: <11861804251625-git-send-email-len.brown@intel.com>
In-Reply-To: <67effe8fff32f60bdf51cba484766ba6003005bb.1186180370.git.len.brown@intel.com>
From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
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>
---
drivers/misc/thinkpad_acpi.c | 10 ++++++++--
drivers/misc/thinkpad_acpi.h | 2 ++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index fa80f35..f6cd34a 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)
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 */
@@ -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);
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 88af089..eee8809 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -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 {
--
1.5.3.rc3.7.gd58e
next prev parent reply other threads:[~2007-08-03 22:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-03 22:33 ACPI patches for 2.6.23-rc2 Len Brown
2007-08-03 22:33 ` [PATCH 01/12] ACPI: add "acpi_no_auto_ssdt" bootparam Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-03 22:33 ` [PATCH 02/12] sony-laptop: restore the last user requested brightness level on resume Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-03 22:33 ` [PATCH 03/12] sony-laptop: sony_nc_ids[] can become static Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-03 22:33 ` [PATCH 04/12] sonypi: fix ids member of struct acpi_driver Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-03 22:33 ` Len Brown [this message]
2007-08-03 22:33 ` [PATCH 05/12] ACPI: thinkpad-acpi: fix the module init failure path Len Brown
2007-08-03 22:33 ` [PATCH 06/12] ACPI: button: re-scan lid state on resume Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-05 15:11 ` Thomas Renninger
2007-08-03 22:33 ` [PATCH 07/12] asus_acpi: fix possible double free (found by Coverity) Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-03 22:33 ` [PATCH 08/12] ACPI: EC: Remove noisy debug printk fron EC driver Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-03 22:33 ` [PATCH 09/12] ACPI: Battery: Synchronize battery operations Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-03 22:33 ` [PATCH 10/12] ACPI: EC: If ECDT is not found, look up EC in DSDT Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-03 22:33 ` [PATCH 11/12] ACPI: EC: fix build warning Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-03 22:33 ` [PATCH 12/12] ACPI: EC: Switch from boot_ec as soon as we find its desc in DSDT Len Brown
2007-08-03 22:33 ` Len Brown
2007-08-08 8:11 ` [PATCH 01/12] ACPI: add "acpi_no_auto_ssdt" bootparam Thomas Renninger
2007-08-08 16:38 ` Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11861804303949-git-send-email-len.brown@intel.com \
--to=len.brown@intel.com \
--cc=hmh@hmh.eng.br \
--cc=linux-acpi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.