Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

asus_acpi: fix oops on non-asus machines

If asus_acpi_init doesn't find any device it knows about, it mistakenly
returns a "success" error code even though it cleans up after itself. Later
when trying to rmmod asus_acpi, the module_exit routine would try to clean up
one more time and we would end up calling
acpi_bus_unregister_driver(&asus_hotk_driver) twice. This patch addresses
this first problem by returning -ENODEV when no appropriate device is found.

Then there was also another bug with the code handling the return value of
backlight_device_register. If this function ever failed, the driver would
cleanup by calling the module_exit routine from module_init, but it would
still return "success". So any attempt to rmmod this module would result in
asus_acpi_exit being called twice but it's not ready to handle it (I haven't
hit this bug, just found it by code inspection). This patch fixes that by
inserting a return -ENODEV; at the end of this error handling path.

Signed-off-by: Maxime Austruy <maxime@tralhalla.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Jan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Maxime Austruy and committed by
Linus Torvalds
5ebffd7c d80d0217

+2 -1
+2 -1
drivers/acpi/asus_acpi.c
··· 1398 1398 if (!asus_hotk_found) { 1399 1399 acpi_bus_unregister_driver(&asus_hotk_driver); 1400 1400 remove_proc_entry(PROC_ASUS, acpi_root_dir); 1401 - return result; 1401 + return -ENODEV; 1402 1402 } 1403 1403 1404 1404 asus_backlight_device = backlight_device_register("asus",NULL,NULL, ··· 1407 1407 printk(KERN_ERR "Could not register asus backlight device\n"); 1408 1408 asus_backlight_device = NULL; 1409 1409 asus_acpi_exit(); 1410 + return -ENODEV; 1410 1411 } 1411 1412 asus_backlight_device->props.max_brightness = 15; 1412 1413