Skip to content

Commit f78fb25

Browse files
ziyao233chenhuacai
authored andcommitted
platform/loongarch: laptop: Unregister generic_sub_drivers on exit
Without correct unregisteration, ACPI notify handlers and the platform drivers installed by generic_subdriver_init() will become dangling references after removing the loongson_laptop module, triggering various kernel faults when a hotkey is sent or at kernel shutdown. Cc: stable@vger.kernel.org Fixes: 6246ed0 ("LoongArch: Add ACPI-based generic laptop driver") Signed-off-by: Yao Zi <ziyao@disroot.org> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 53c762b commit f78fb25

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/platform/loongarch/loongson-laptop.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,17 @@ static int __init generic_acpi_laptop_init(void)
612612

613613
static void __exit generic_acpi_laptop_exit(void)
614614
{
615+
int i;
616+
615617
if (generic_inputdev) {
616-
if (input_device_registered)
617-
input_unregister_device(generic_inputdev);
618-
else
618+
if (!input_device_registered) {
619619
input_free_device(generic_inputdev);
620+
} else {
621+
input_unregister_device(generic_inputdev);
622+
623+
for (i = 0; i < ARRAY_SIZE(generic_sub_drivers); i++)
624+
generic_subdriver_exit(&generic_sub_drivers[i]);
625+
}
620626
}
621627
}
622628

0 commit comments

Comments
 (0)