Re: [PATCH 7/7] [RFC] APM emulation driver for class batteries
- From: Pavel Machek <pavel@xxxxxx>
- Date: Fri, 20 Apr 2007 10:27:46 +0200
Hi!
+static void (*old_apm_get_power_status)(struct apm_power_info*);
+
+static int __init apm_battery_init(void)
+{
+ printk(KERN_INFO "APM Battery Driver\n");
+
+ old_apm_get_power_status = apm_get_power_status;
+ apm_get_power_status = apm_battery_apm_get_power_status;
+ return 0;
+}
+
+static void __exit apm_battery_exit(void)
+{
+ apm_get_power_status = old_apm_get_power_status;
+ return;
+}
Utterly unsafe. What happens if some other module gets loaded which
does this, and then this module is unloaded followed by the other
module. Result: Oops.
Right. And loading two modules which changing apm_get_power_status
is a race already. Thus, APM interface needs a mutex.
Or pda_power should be marked "bool" in Kconfig, as it is done
in arch/arm/common/sharpsl_pm.c. Sharpsl_pm is safe only because it
can't be a module.
Just mark it bool, when you fix it with mutex, you can go back to
tristate.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- References:
- [PATCH 7/7] [RFC] APM emulation driver for class batteries
- From: Anton Vorontsov
- Re: [PATCH 7/7] [RFC] APM emulation driver for class batteries
- From: Anton Vorontsov
- Re: [PATCH 7/7] [RFC] APM emulation driver for class batteries
- From: Russell King
- Re: [PATCH 7/7] [RFC] APM emulation driver for class batteries
- From: Anton Vorontsov
- [PATCH 7/7] [RFC] APM emulation driver for class batteries
- Prev by Date: Re: Acecad USB Tablet: usbmouse takeover and odd motion
- Next by Date: const struct pci_driver [Was: [RFC 2/2] Input: phantom, add a new driver]
- Previous by thread: Re: [PATCH 7/7] [RFC] APM emulation driver for class batteries
- Next by thread: Re: [Kernel-discuss] Re: [PATCH 7/7] [RFC] APM emulation driver for class batteries
- Index(es):
Relevant Pages
|
Loading