ACPI / dock: Take ACPI scan lock in write_undock()
PATCH 1/1 ACPI / dock: Take ACPI scan lock in write_undock()
From: Rafael J. Wysocki <[email protected]>
Since commit 3757b94 (ACPI / hotplug: Fix concurrency issues and memory leaks) acpi_bus_scan() and acpi_bus_trim() must always be called under acpi_scan_lock, but currently the following scenario violating that requirement is possible:
write_undock()
handle_eject_request()
hotplug_dock_devices()
dock_remove_acpi_device()
acpi_bus_trim()Fix that by making write_undock() acquire acpi_scan_lock before calling handle_eject_request() as appropriate (begin_undock() is under the lock too in analogy with acpi_dock_deferred_cb()).
--- drivers/acpi/dock.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/acpi/dock.c +2 -0
@@ -868,8 +868,10 @@ static ssize_t write_undock(struct devicif (!count)return -EINVAL ; +acpi_scan_lock_acquire ();begin_undock (dock_station); ret =handle_eject_request (dock_station,ACPI_NOTIFY_EJECT_REQUEST ); +acpi_scan_lock_release ();return ret ? ret: count; } static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
Quoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Since commit 3757b94 (ACPI / hotplug: Fix concurrency issues and memory leaks)
acpi_bus_scan()andacpi_bus_trim()must always be called underacpi_scan_lock, but currently the following scenario violating that requirement is possible:
write_undock()
handle_eject_request()
hotplug_dock_devices()
Quoted 8 lines
dock_remove_acpi_device() acpi_bus_trim()Fix that by making
write_undock()acquireacpi_scan_lockbefore callinghandle_eject_request()as appropriate (begin_undock()is under the lock too in analogy withacpi_dock_deferred_cb()).Signed-off-by Rafael J. Wysocki <[email protected]>
Looks good.
Thanks,
-Toshi
Quoted 21 lines
Cc 3.9+ <[email protected]>--- drivers/acpi/dock.c | 2 ++ 1 file changed, 2 insertions(+)Index:
linux-pm/drivers/acpi/dock.c
===================================================================drivers/acpi/dock.c +2
-0@@ -868,8 +868,10 @@ static ssize_t write_undock(struct devicif (!count)return -EINVAL ; +acpi_scan_lock_acquire ();begin_undock (dock_station); ret =handle_eject_request (dock_station,ACPI_NOTIFY_EJECT_REQUEST ); +acpi_scan_lock_release ();return ret ? ret: count; } static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
Quoted 18 lines · Toshi Kani
Quoted 17 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Since commit 3757b94 (ACPI / hotplug: Fix concurrency issues and memory leaks)
acpi_bus_scan()andacpi_bus_trim()must always be called underacpi_scan_lock, but currently the following scenario violating that requirement is possible:
write_undock()
handle_eject_request()
hotplug_dock_devices()dock_remove_acpi_device() acpi_bus_trim()Fix that by making
write_undock()acquireacpi_scan_lockbefore callinghandle_eject_request()as appropriate (begin_undock()is under the lock too in analogy withacpi_dock_deferred_cb()).
Quoted 5 lines
Quoted 1 line
Signed-off-by Rafael J. Wysocki <[email protected]>Looks good.
Acked-by Toshi Kani <[email protected]>
Thanks!
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.