DragonFlyBSD Kernel Audit
DF-2228 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/gnu/dev/misc/apple_gmux/apple-gmux.c b/sys/gnu/dev/misc/apple_gmux/apple-gmux.c
--- a/sys/gnu/dev/misc/apple_gmux/apple-gmux.c
+++ b/sys/gnu/dev/misc/apple_gmux/apple-gmux.c
@@ -918,6 +918,14 @@
 	gmux_disable_interrupts(sc);
 	if (sc->gpe >= 0) {
 		AcpiDisableGpe(NULL, sc->gpe);
+		/* DragonFly's AcpiOsWaitEventsComplete() is a no-op
+		   (acdragonfly.h:219-220), so a deferred AcpiEvNotifyDispatch
+		   queued before AcpiDisableGpe can still run after
+		   AcpiRemoveNotifyHandler frees the handler object.  Yield to
+		   the ACPI helper thread to drain in-flight dispatches before
+		   the remove/frees below race the handler (systemic root cause
+		   is the no-op stub; this is a best-effort mitigation). */
+		AcpiOsSleep(10);
 		AcpiRemoveNotifyHandler(sc->dhandle, ACPI_DEVICE_NOTIFY,
 					gmux_notify_handler);
 	}