Armin Wolf ca26e8eed9 ACPI: battery: Fix possible crash when unregistering a battery hook
[ Upstream commit 76959aff14a0012ad6b984ec7686d163deccdc16 ]

When a battery hook returns an error when adding a new battery, then
the battery hook is automatically unregistered.
However the battery hook provider cannot know that, so it will later
call battery_hook_unregister() on the already unregistered battery
hook, resulting in a crash.

Fix this by using the list head to mark already unregistered battery
hooks as already being unregistered so that they can be ignored by
battery_hook_unregister().

Fixes: fa93854f7a7e ("battery: Add the battery hooking API")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/20241001212835.341788-3-W_Armin@gmx.de
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-10-10 12:01:12 +02:00
..
2024-04-08 16:10:27 +02:00
2024-03-19 18:30:54 -07:00
2024-04-08 16:10:27 +02:00
2024-03-27 16:36:45 +01:00
2023-09-21 20:55:43 +02:00
2022-01-22 08:33:37 +02:00
2020-11-09 19:08:06 +01:00
2024-03-19 11:15:14 -07:00
2023-03-27 20:50:28 +02:00
2020-11-09 19:08:06 +01:00