summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2021-09-13 12:17:53 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-10-02 11:32:56 +0200
commit95874e48388935c53684832176f3fdf30f18dd4a (patch)
tree26d3a844a7db65b867e58bee70eebc9e2a21a726 /drivers
parentb51b15ba173825124ba6f21387183357a5dd6d1c (diff)
downloadbarebox-95874e48388935c53684832176f3fdf30f18dd4a.tar.gz
barebox-95874e48388935c53684832176f3fdf30f18dd4a.tar.xz
base: driver: fix double removal of child devices
Child devices like an ext4 file system on a partition may be removed twice: Once because they're in the active devices list and then once more, because unregister_device is called for the children of its parent. As struct bus_type::remove clears association of a driver with its device, we can set struct device_d::driver to NULL. unregister_device will then skip the second dev->bus->remove. Fixes: 29f1c211d86c ("fs: don't free device in remove callback") Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20210913101753.465831-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/driver.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 0e04ef3686..23d11d4dad 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -511,8 +511,10 @@ static void devices_shutdown(void)
struct device_d *dev;
list_for_each_entry(dev, &active, active) {
- if (dev->bus->remove)
+ if (dev->bus->remove) {
dev->bus->remove(dev);
+ dev->driver = NULL;
+ }
}
}
devshutdown_exitcall(devices_shutdown);