lkml.org 
[lkml]   [2020]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] driver core: platform: don't oops on unbound devices
Date
Platform code stopped checking if the device is bound to the actual
platform driver, thus calling non-existing drv->shutdown(). Verify that
_dev->driver is not NULL before calling remove/shutdown callbacks.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Fixes: 9c30921fe799 ("driver core: platform: use bus_type functions")
---
drivers/base/platform.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 0358dc3ea3ad..93f44e69b472 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1342,7 +1342,7 @@ static int platform_remove(struct device *_dev)
struct platform_device *dev = to_platform_device(_dev);
int ret = 0;

- if (drv->remove)
+ if (_dev->driver && drv->remove)
ret = drv->remove(dev);
dev_pm_domain_detach(_dev, true);

@@ -1354,7 +1354,7 @@ static void platform_shutdown(struct device *_dev)
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);

- if (drv->shutdown)
+ if (_dev->driver && drv->shutdown)
drv->shutdown(dev);
}

--
2.29.2
\
 
 \ /
  Last update: 2020-12-12 02:19    [W:0.068 / U:1.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site