regulator: core: fix module refcount leak in set_supply()

[ Upstream commit da46ee19cb ]

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

Fixes: e2c09ae7a7 ("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>
This commit is contained in:
Yang Yingliang 2022-12-01 20:27:05 +08:00 коммит произвёл Greg Kroah-Hartman
Родитель 66976a3be9
Коммит 91657ec4d0
1 изменённых файлов: 1 добавлений и 0 удалений

Просмотреть файл

@ -1577,6 +1577,7 @@ static int set_supply(struct regulator_dev *rdev,
rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY"); rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY");
if (rdev->supply == NULL) { if (rdev->supply == NULL) {
module_put(supply_rdev->owner);
err = -ENOMEM; err = -ENOMEM;
return err; return err;
} }