diff options
author | Dmitry Baryshkov <dmitry.baryshkov@linaro.org> | 2020-12-13 02:55:33 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-12-13 16:03:42 +0100 |
commit | 46e85af0cc53f35584e00bb5db7db6893d0e16e5 (patch) | |
tree | a8c29c86ab412b3783e9d837229233fc395fd650 /drivers/base/platform.c | |
parent | 2ab695aa8eb8f3226f68a2b91fc6103b56fcb57d (diff) |
driver core: platform: don't oops in platform_shutdown() on unbound devices
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 <linux@roeck-us.net>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20201212235533.247537-1-dmitry.baryshkov@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r-- | drivers/base/platform.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 0358dc3ea3ad..e9477e0bbca5 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -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); } |