linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] reset: bail if try_module_get() fails
@ 2021-06-07  8:26 Philipp Zabel
  2021-06-07  8:36 ` Uwe Kleine-König
  0 siblings, 1 reply; 2+ messages in thread
From: Philipp Zabel @ 2021-06-07  8:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: Uwe Kleine-König, kernel

Abort instead of returning a new reset control for a reset controller
device that is going to have its module unloaded.

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/reset/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 63852076a5a3..61e688882643 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -774,7 +774,10 @@ __reset_control_get_internal(struct reset_controller_dev *rcdev,
 	if (!rstc)
 		return ERR_PTR(-ENOMEM);
 
-	try_module_get(rcdev->owner);
+	if (!try_module_get(rcdev->owner)) {
+		kfree(rstc);
+		return ERR_PTR(-ENODEV);
+	}
 
 	rstc->rcdev = rcdev;
 	list_add(&rstc->list, &rcdev->reset_control_head);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] reset: bail if try_module_get() fails
  2021-06-07  8:26 [PATCH] reset: bail if try_module_get() fails Philipp Zabel
@ 2021-06-07  8:36 ` Uwe Kleine-König
  0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2021-06-07  8:36 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-kernel, kernel

[-- Attachment #1: Type: text/plain, Size: 674 bytes --]

On Mon, Jun 07, 2021 at 10:26:15AM +0200, Philipp Zabel wrote:
> Abort instead of returning a new reset control for a reset controller
> device that is going to have its module unloaded.
> 
> Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

LGTM:

Fixes: 61fc41317666 ("reset: Add reset controller API")
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks for picking up my report from irc :-)

Best regards
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] 2+ messages in thread

end of thread, other threads:[~2021-06-07  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07  8:26 [PATCH] reset: bail if try_module_get() fails Philipp Zabel
2021-06-07  8:36 ` 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).