driver core: Release all resources during unbind before updating device links

commit 2e84dc37920012b458e9458b19fc4ed33f81bc74 upstream.

This commit fixes a bug in commit 9ed9895370 ("driver core: Functional
dependencies tracking support") where the device link status was
incorrectly updated in the driver unbind path before all the device's
resources were released.

Fixes: 9ed9895370 ("driver core: Functional dependencies tracking support")
Cc: stable <[email protected]>
Reported-by: Uwe Kleine-König <[email protected]>
Closes: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Saravana Kannan <[email protected]>
Cc: Thierry Reding <[email protected]>
Cc: Yang Yingliang <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Matti Vaittinen <[email protected]>
Cc: James Clark <[email protected]>
Acked-by: "Rafael J. Wysocki" <[email protected]>
Tested-by: Uwe Kleine-König <[email protected]>
Acked-by: Uwe Kleine-König <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
Saravana Kannan 2023-10-17 18:38:50 -07:00 • committed by Greg Kroah-Hartman
commit d359886a7a

View file

@ -1162,8 +1162,6 @@ static void __device_release_driver(struct device *dev, struct device *parent)
else if (drv->remove)
drv->remove(dev);
device_links_driver_cleanup(dev);
devres_release_all(dev);
arch_teardown_dma_ops(dev);
dev->driver = NULL;
@ -1173,6 +1171,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
pm_runtime_reinit(dev);
dev_pm_set_driver_flags(dev, 0);
device_links_driver_cleanup(dev);
klist_remove(&dev->p->knode_driver);
device_pm_check_callbacks(dev);
if (dev->bus)