From: Felix Gu Date: Mon, 4 May 2026 14:53:26 +0000 (+0800) Subject: pinctrl: sunxi: fix regulator leak in sunxi_pmx_request() error path X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=334f7bcbdc79dc8e5b938ac3372453a5368221cf;p=thirdparty%2Fkernel%2Flinux.git pinctrl: sunxi: fix regulator leak in sunxi_pmx_request() error path 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 Reviewed-by: Andre Przywara Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index d3042e0c9712e..25489beeb3125 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -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; }