diff --git a/drivers/reset/core.c b/drivers/reset/core.c index dbf881b586d9d..fd7e1a3525f45 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -640,7 +640,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);