Commit 4fb26fb8 authored by Philipp Zabel's avatar Philipp Zabel

reset: bail if try_module_get() fails

Abort instead of returning a new reset control for a reset controller
device that is going to have its module unloaded.
Reported-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fixes: 61fc4131 ("reset: Add reset controller API")
Acked-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20210607082615.15160-1-p.zabel@pengutronix.deSigned-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent 91105ed6
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment