]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pinctrl: sunxi: fix regulator leak in sunxi_pmx_request() error path
authorFelix Gu <ustc.gu@gmail.com>
Mon, 4 May 2026 14:53:26 +0000 (22:53 +0800)
committerLinus Walleij <linusw@kernel.org>
Tue, 5 May 2026 09:25:46 +0000 (11:25 +0200)
In the error path of sunxi_pmx_request(), the code calls
regulator_put(s_reg->regulator) to release the regulator. However,
s_reg->regulator is only assigned after a successful regulator_enable().
This causes a memory leak: the regulator obtained via regulator_get()
is never properly released when regulator_enable() fails.

Fixes: dc1445584177 ("pinctrl: sunxi: Fix and simplify pin bank regulator handling")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>
drivers/pinctrl/sunxi/pinctrl-sunxi.c

index d3042e0c9712e888a9bb24f20aa42341e75afbe7..25489beeb312537ae69b3e61aedb676feabb23eb 100644 (file)
@@ -925,7 +925,7 @@ static int sunxi_pmx_request(struct pinctrl_dev *pctldev, unsigned offset)
        return 0;
 
 out:
-       regulator_put(s_reg->regulator);
+       regulator_put(reg);
 
        return ret;
 }