Skip to content

Commit

Permalink
regulator: core: fix module refcount leak in set_supply()
Browse files Browse the repository at this point in the history
[ Upstream commit da46ee1 ]

If create_regulator() fails in set_supply(), the module refcount
needs be put to keep refcount balanced.

Fixes: e2c09ae ("regulator: core: Increase refcount for regulator supply's module")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221201122706.4055992-2-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yang Yingliang authored and gregkh committed Dec 31, 2022
1 parent 66976a3 commit 91657ec
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/regulator/core.c
Expand Up @@ -1577,6 +1577,7 @@ static int set_supply(struct regulator_dev *rdev,

rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY");
if (rdev->supply == NULL) {
module_put(supply_rdev->owner);
err = -ENOMEM;
return err;
}
Expand Down

0 comments on commit 91657ec

Please sign in to comment.