⬢ DragonFlyBSD Kernel Audit
DF-4286 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/acpica/acpi_thinkpad/acpi_thinkpad.c
+++ b/sys/dev/acpica/acpi_thinkpad/acpi_thinkpad.c
@@ -656,6 +656,14 @@ acpi_thinkpad_detach(device_t dev)
 	if (sc->led_dev != NULL)
 		led_destroy(sc->led_dev);
 
+	/*
+	 * led_destroy() only waits for the led(4) cdev; a thinkpad_led_task()
+	 * queued via AcpiOsExecute() may still be pending and dereferences
+	 * sc (ACPI_SERIAL, sysctl_set, EC accessors).  Drain it before the
+	 * softc goes away.
+	 */
+	while (sc->led_busy)
+		tsleep(&sc->led_busy, 0, "tpled", hz);
+
 	return (0);
 }