summaryrefslogtreecommitdiff
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-12-01 20:27:05 +0800
committerMark Brown <broonie@kernel.org>2022-12-01 17:19:12 +0000
commitda46ee19cbd8344d6860816b4827a7ce95764867 (patch)
tree149a00cffcfa9e13fbf2d2f8e6545b011ba7444b /drivers/regulator/core.c
parent0591b14ce0398125439c759f889647369aa616a0 (diff)
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: e2c09ae7a74d ("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>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 866401f3fb10..76630c2c4180 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1646,6 +1646,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;
}