summaryrefslogtreecommitdiffstats
path: root/drivers/reset
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2021-06-07 10:26:15 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-20 16:16:14 +0200
commit4bb145e596e9308d086b336a61794f0c331c4f34 (patch)
tree4d0bc8b30d9c91b6058abc55167244131a6d66e4 /drivers/reset
parent8cb5a0522b5f6a15e9223d3a315c2e0041e02550 (diff)
downloadlinux-stable-4bb145e596e9308d086b336a61794f0c331c4f34.tar.gz
linux-stable-4bb145e596e9308d086b336a61794f0c331c4f34.tar.bz2
linux-stable-4bb145e596e9308d086b336a61794f0c331c4f34.zip
reset: bail if try_module_get() fails
[ Upstream commit 4fb26fb83f0def3d39c14e268bcd4003aae8fade ] 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> Fixes: 61fc41317666 ("reset: Add reset controller API") Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20210607082615.15160-1-p.zabel@pengutronix.de Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/reset')
-rw-r--r--drivers/reset/core.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index f7bf20493f23..ccb97f4e31c3 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -428,7 +428,10 @@ static struct reset_control *__reset_control_get_internal(
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);