ACPI: bus: Ensure that notify handlers are not running after removal
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 14 Apr 2023 14:00:48 +0000 (16:00 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 18 Apr 2023 15:40:45 +0000 (17:40 +0200)
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")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/bus.c

index 2f2517d6f9ef9fb0a54c121cc32974dda6e9abc1..c32a06bcac0cf343f7c9980bb8652619e975751f 100644 (file)
@@ -589,6 +589,7 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device,
                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) */