summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorPingfan Liu <kernelfans@gmail.com>2018-07-19 13:14:58 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-26 08:36:34 +0200
commite6f55802bac406cd1894351ac8b13aa5d5459da6 (patch)
treeaed9c60868e4657a268ec90a33eecebf181561b7 /drivers/base
parent0a10ce961bb34a0a42e60534479d8a79fc46d927 (diff)
drivers/base: stop new probing during shutdown
[ Upstream commit 3297c8fc65af5d40501ea7cddff1b195cae57e4e ] There is a race window in device_shutdown(), which may cause -1. parent device shut down before child or -2. no shutdown on a new probing device. For 1st, taking the following scenario: device_shutdown new plugin device list_del_init(parent_dev); spin_unlock(list_lock); device_add(child) probe child shutdown parent_dev --> now child is on the tail of devices_kset For 2nd, taking the following scenario: device_shutdown new plugin device device_add(dev) device_lock(dev); ... device_unlock(dev); probe dev --> now, the new occurred dev has no opportunity to shutdown To fix this race issue, just prevent the new probing request. With this logic, device_shutdown() is more similar to dpm_prepare(). Signed-off-by: Pingfan Liu <kernelfans@gmail.com> Reviewed-by: Rafael J. Wysocki <rafael@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a0ed957d738f..f43caad30e1e 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2072,6 +2072,9 @@ void device_shutdown(void)
{
struct device *dev, *parent;
+ wait_for_device_probe();
+ device_block_probing();
+
spin_lock(&devices_kset->list_lock);
/*
* Walk the devices list backward, shutting down each in turn.