[PATCH] ARM: pxa: unset apm_get_power_status on unload

Ahelenia Ziemiańska nabijaczleweli at nabijaczleweli.xyz
Thu Oct 16 15:05:14 PDT 2025


The API for apm_get_power_status is "call it if it isn't NULL".
If the module is unloaded and it's not unset,
reading /proc/apm will jump into unloaded kernel memory.

Unset it on unload like drivers/macintosh/apm_emu.c.

Also, use the forward declaration from apm-emulation.h.

Fixes: 078abcf95cdb ("[ARM] 3096/1: Add SharpSL Zaurus power and battery management core driver")
Fixes: b7557de41a04 ("[ARM] 3228/1: SharpSL: Move PM code to arch/arm/common")
Fixes: 78731d33c186 ("[ARM] pxa/sharpsl_pm: merge the two sharpsl_pm.c since it's now pxa specific")
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli at nabijaczleweli.xyz>
---
 arch/arm/mach-pxa/sharpsl_pm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index 71b282b146d0..cc6eba5419c8 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -795,8 +795,6 @@ static ssize_t battery_voltage_show(struct device *dev, struct device_attribute
 static DEVICE_ATTR_RO(battery_percentage);
 static DEVICE_ATTR_RO(battery_voltage);
 
-extern void (*apm_get_power_status)(struct apm_power_info *);
-
 static void sharpsl_apm_get_power_status(struct apm_power_info *info)
 {
 	info->ac_line_status = sharpsl_pm.battstat.ac_status;
@@ -892,6 +890,9 @@ static void sharpsl_pm_remove(struct platform_device *pdev)
 {
 	suspend_set_ops(NULL);
 
+	if (apm_get_power_status == sharpsl_apm_get_power_status)
+		apm_get_power_status = NULL;
+
 	device_remove_file(&pdev->dev, &dev_attr_battery_percentage);
 	device_remove_file(&pdev->dev, &dev_attr_battery_voltage);
 
-- 
2.39.5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20251017/b785618a/attachment.sig>


More information about the linux-arm-kernel mailing list