[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221201122706.4055992-2-yangyingliang@huawei.com>
Date: Thu, 1 Dec 2022 20:27:05 +0800
From: Yang Yingliang <yangyingliang@...wei.com>
To: <lgirdwood@...il.com>, <broonie@...nel.org>,
<javier@....samsung.com>, <mirq-linux@...e.qmqm.pl>,
<christian@...lschutter.com>
CC: <linux-kernel@...r.kernel.org>
Subject: [PATCH 1/2] 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@...wei.com>
---
drivers/regulator/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index bc4bba899aea..4a7d8ec415e8 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1638,10 +1638,11 @@ static int set_supply(struct regulator_dev *rdev,
if (!try_module_get(supply_rdev->owner))
return -ENODEV;
rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY");
if (rdev->supply == NULL) {
+ module_put(supply_rdev->owner);
err = -ENOMEM;
return err;
}
supply_rdev->open_count++;
--
2.25.1
Powered by blists - more mailing lists