Skip to content

Commit da46ee1

Browse files
Yang Yingliangbroonie
authored andcommitted
regulator: core: fix module refcount leak in set_supply()
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>
1 parent 0591b14 commit da46ee1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/regulator/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,7 @@ static int set_supply(struct regulator_dev *rdev,
16461646

16471647
rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY");
16481648
if (rdev->supply == NULL) {
1649+
module_put(supply_rdev->owner);
16491650
err = -ENOMEM;
16501651
return err;
16511652
}

0 commit comments

Comments
 (0)