[PATCH] sh: hp6xx: unset apm_get_power_status on unload

Ahelenia Ziemiańska <[email protected]>
Newsgroups gmane.linux.ports.sh.devel,gmane.linux.kernel
Message-ID <ydtnrqqjuaz6uifqplujmqwdnpxoe7ma33d5hp4waavekerod2@tarta.nabijaczleweli.xyz>
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.

The first commit that added this incompletely refactored
the assigned-to variable in __exit,
the second deleted it instead of fixing it.

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

Fixes: 0a9b0db19262 ("[APM] SH: Convert to use shared APM emulation.")
Fixes: 8c8ee8254767 ("sh: hp6xx: APM build fix and new battery values.")
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
---
 arch/sh/boards/mach-hp6xx/hp6xx_apm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/sh/boards/mach-hp6xx/hp6xx_apm.c b/arch/sh/boards/mach-hp6xx/hp6xx_apm.c
index e5c4c7d34139..089eca39c4e6 100644
--- a/arch/sh/boards/mach-hp6xx/hp6xx_apm.c
+++ b/arch/sh/boards/mach-hp6xx/hp6xx_apm.c
@@ -98,6 +98,9 @@ static int __init hp6x0_apm_init(void)
 
 static void __exit hp6x0_apm_exit(void)
 {
+	if (apm_get_power_status == hp6x0_apm_get_power_status)
+		apm_get_power_status = NULL;
+
 	free_irq(HP680_BTN_IRQ, 0);
 }
 
-- 
2.39.5
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmjxbBwACgkQvP0LAY0m
WPH3KA//U1fjA6GQZjwTQGkOuBhgN5DIwPgQ0S3sEx2P0ExvqCiyxzM5iO1xr3oP
iMwWyZukLxQ5hhMpRHdWizQiJjEQSWaUJfp58xNtfXiE7F7V7GPd3BN8q6osJTEt
TMBP02Idm9nDCFqbA9/AWAmL4Fvkn2erqIQVL9fWu6zfykySHbNzq6lKhtrBnK32
3tA1ngQcjKQf1SJl0hc/9Kij49j8TjzN5SyYxt9giqT6SbLAfi7W6UQDoiRhnzq/
9qWabu56d/g8XnzjJCfHM6Ei4GoN5aFucv5ieg8z5prT6MrZzgDXYA+bGt22AK0K
ZN1lGAB6yKzUnbyEhEzLsqNcka+twqaXsVjTMe+sWW0cKdxi7hsPv9yW5/upEpmC
gIp7/ldRCeFJWyNU+Xq+fC/eZyMqj+FzyxgVg3pp3IAaFFK/XJeTK95Ut5jX3QLR
AGJr+iw6lMdPoB04+SowtEq8ZZhc6jAsvH0KGba6z57PfpXaH3dUQsrzDt4RMArD
fazqosY5g55mcPY8sSJ1ftHG2/LHBUHVaz+0q50TKM9jQDF/zC9DgRkQH91tiXr+
BYzpXVUYufdpdkBWBfhP6T+a298MIE20i2RH2lkESm5c7v6kD+IPpZQBZ4siXKnD
p29Sy6c6QDdnCL6xWnAQQH5hTjV3Z+3AiBuHwXcTT6/qg9Bt5C0=
=yztO
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.