Unverified Commit da46ee19 authored by Yang Yingliang's avatar Yang Yingliang Committed by Mark Brown
Browse files

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: e2c09ae7 ("regulator: core: Increase refcount for regulator supply's module")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221201122706.4055992-2-yangyingliang@huawei.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0591b14c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
	}