Skip to contentSkip to conversation

ACPI: bus: Ensure that notify handlers are not running after removal

PATCH New Rafael J. Wysocki 1 participant 1 message Apr 14, 2023 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: bus: Ensure that notify handlers are not running after removal

From: Rafael J. Wysocki <[email protected]>

Currently, acpi_device_remove_notify_handler() may return while the notify handler being removed is still running which may allow the module holding that handler to be torn down prematurely.

Address this issue by making acpi_device_remove_notify_handler() wait for the handling of all the ACPI events in progress to complete before returning.

Fixes 5894b0c46e49 ("ACPI / scan: Move bus operations and notification routines to bus.c")
---
 drivers/acpi/bus.c |    1 +
 1 file changed, 1 insertion(+)
drivers/acpi/bus.c +1 -0
Index: linux-pm/drivers/acpi/bus.c
===================================================================
@@ -589,6 +589,7 @@ static void acpi_device_remove_notify_ha
 		acpi_remove_notify_handler(device->handle, type,
 					   acpi_notify_device);
 	}
+	acpi_os_wait_events_complete();
 }
 
 /* Handle events targeting \_SB device (at present only graceful shutdown) */