]> Git Repo - linux.git/commitdiff
driver core: platform: don't oops in platform_shutdown() on unbound devices
authorDmitry Baryshkov <[email protected]>
Sat, 12 Dec 2020 23:55:33 +0000 (02:55 +0300)
committerGreg Kroah-Hartman <[email protected]>
Sun, 13 Dec 2020 15:03:42 +0000 (16:03 +0100)
On shutdown the driver core calls the bus' shutdown callback also for
unbound devices. A driver's shutdown callback however is only called for
devices bound to this driver. Commit 9c30921fe799 ("driver core:
platform: use bus_type functions") changed the platform bus from driver
callbacks to bus callbacks, so the shutdown function must be prepared to
be called without a driver. Add the corresponding check in the shutdown
function.

Fixes: 9c30921fe799 ("driver core: platform: use bus_type functions")
Tested-by: Guenter Roeck <[email protected]>
Reviewed-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Dmitry Baryshkov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/base/platform.c

index 0358dc3ea3ad623735376991b526a0134aeab5d0..e9477e0bbca59dc1a39d4499dfc6d144541dd291 100644 (file)
@@ -1351,9 +1351,13 @@ static int platform_remove(struct device *_dev)
 
 static void platform_shutdown(struct device *_dev)
 {
-       struct platform_driver *drv = to_platform_driver(_dev->driver);
        struct platform_device *dev = to_platform_device(_dev);
+       struct platform_driver *drv;
+
+       if (!_dev->driver)
+               return;
 
+       drv = to_platform_driver(_dev->driver);
        if (drv->shutdown)
                drv->shutdown(dev);
 }
This page took 0.056157 seconds and 4 git commands to generate.