When hotplug.autoeject and uevents are enabled, it crashes in kobject_uevent() since the device is no longer valid. This patch fixes the problem. Reported-by: Toshi Kani Signed-off-by: Yasuaki Ishimatsu --- drivers/acpi/scan.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c 2013-02-22 16:02:07.000000000 +0900 +++ linux-pm/drivers/acpi/scan.c 2013-02-22 16:06:36.792816699 +0900 @@ -139,9 +139,6 @@ static int acpi_scan_hot_remove(struct a "Hot-removing device %s...\n", dev_name(&device->dev))); acpi_bus_trim(device); - /* Device node has been unregistered. */ - put_device(&device->dev); - device = NULL; if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", ¬_used))) { arg_list.count = 1; @@ -191,10 +188,10 @@ static void acpi_bus_device_eject(void * } acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); + get_device(&device->dev); if (handler->hotplug.autoeject) { int error; - get_device(&device->dev); error = acpi_scan_hot_remove(device); if (error) goto err_out; @@ -204,6 +201,7 @@ static void acpi_bus_device_eject(void * if (handler->hotplug.uevents) kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); + put_device(&device->dev); out: mutex_unlock(&acpi_scan_lock); return; @@ -312,6 +310,7 @@ void acpi_bus_hot_remove_device(void *co ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL); + put_device(&acpi_device->dev); mutex_unlock(&acpi_scan_lock); kfree(context); }