* [PATCH] ACPI / dock: Take ACPI scan lock in write_undock()
@ 2013-06-15 22:16 Rafael J. Wysocki
2013-06-18 21:28 ` Toshi Kani
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2013-06-15 22:16 UTC (permalink / raw)
To: ACPI Devel Maling List; +Cc: Toshi Kani, LKML, Jiang Liu, Yinghai Lu
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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()).
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: 3.9+ <stable@vger.kernel.org>
---
drivers/acpi/dock.c | 2 ++
1 file changed, 2 insertions(+)
Index: linux-pm/drivers/acpi/dock.c
===================================================================
--- linux-pm.orig/drivers/acpi/dock.c
+++ linux-pm/drivers/acpi/dock.c
@@ -868,8 +868,10 @@ static ssize_t write_undock(struct devic
if (!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);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI / dock: Take ACPI scan lock in write_undock()
2013-06-15 22:16 [PATCH] ACPI / dock: Take ACPI scan lock in write_undock() Rafael J. Wysocki
@ 2013-06-18 21:28 ` Toshi Kani
2013-06-18 21:43 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Toshi Kani @ 2013-06-18 21:28 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: ACPI Devel Maling List, LKML, Jiang Liu, Yinghai Lu
On Sun, 2013-06-16 at 00:16 +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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()).
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Looks good.
Acked-by: Toshi Kani <toshi.kani@hp.com>
Thanks,
-Toshi
> Cc: 3.9+ <stable@vger.kernel.org>
> ---
> drivers/acpi/dock.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> Index: linux-pm/drivers/acpi/dock.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/dock.c
> +++ linux-pm/drivers/acpi/dock.c
> @@ -868,8 +868,10 @@ static ssize_t write_undock(struct devic
> if (!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);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI / dock: Take ACPI scan lock in write_undock()
2013-06-18 21:28 ` Toshi Kani
@ 2013-06-18 21:43 ` Rafael J. Wysocki
0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2013-06-18 21:43 UTC (permalink / raw)
To: Toshi Kani; +Cc: ACPI Devel Maling List, LKML, Jiang Liu, Yinghai Lu
On Tuesday, June 18, 2013 03:28:37 PM Toshi Kani wrote:
> On Sun, 2013-06-16 at 00:16 +0200, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > 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()).
> >
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Looks good.
>
> Acked-by: Toshi Kani <toshi.kani@hp.com>
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-06-18 21:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-15 22:16 [PATCH] ACPI / dock: Take ACPI scan lock in write_undock() Rafael J. Wysocki
2013-06-18 21:28 ` Toshi Kani
2013-06-18 21:43 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox