* [PATCH v3] driver core: platform: don't oops in platform_shutdown() on unbound devices
@ 2020-12-12 23:55 Dmitry Baryshkov
2020-12-13 1:36 ` Guenter Roeck
2020-12-13 10:29 ` Uwe Kleine-König
0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2020-12-12 23:55 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Uwe Kleine-König
Cc: linux-kernel, Marek Szyprowski
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.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Fixes: 9c30921fe799 ("driver core: platform: use bus_type functions")
---
drivers/base/platform.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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);
}
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] driver core: platform: don't oops in platform_shutdown() on unbound devices
2020-12-12 23:55 [PATCH v3] driver core: platform: don't oops in platform_shutdown() on unbound devices Dmitry Baryshkov
@ 2020-12-13 1:36 ` Guenter Roeck
2020-12-13 10:29 ` Uwe Kleine-König
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2020-12-13 1:36 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Uwe Kleine-König,
linux-kernel, Marek Szyprowski
On Sun, Dec 13, 2020 at 02:55:33AM +0300, Dmitry Baryshkov wrote:
> 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.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Fixes: 9c30921fe799 ("driver core: platform: use bus_type functions")
Tested-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/base/platform.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> 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);
> }
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] driver core: platform: don't oops in platform_shutdown() on unbound devices
2020-12-12 23:55 [PATCH v3] driver core: platform: don't oops in platform_shutdown() on unbound devices Dmitry Baryshkov
2020-12-13 1:36 ` Guenter Roeck
@ 2020-12-13 10:29 ` Uwe Kleine-König
1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2020-12-13 10:29 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel, Marek Szyprowski
[-- Attachment #1: Type: text/plain, Size: 928 bytes --]
On Sun, Dec 13, 2020 at 02:55:33AM +0300, Dmitry Baryshkov wrote:
> 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.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Fixes: 9c30921fe799 ("driver core: platform: use bus_type functions")
nice commit log :-)
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-13 10:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-12 23:55 [PATCH v3] driver core: platform: don't oops in platform_shutdown() on unbound devices Dmitry Baryshkov
2020-12-13 1:36 ` Guenter Roeck
2020-12-13 10:29 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).