From: Ioana Ciornei Date: Mon, 22 Sep 2025 14:24:21 +0000 (+0300) Subject: gpio: regmap: fix memory leak of gpio_regmap structure X-Git-Tag: v6.16.10~56 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6021d412108f704beee4b43b982dd9ef612d506c;p=thirdparty%2Fkernel%2Fstable.git gpio: regmap: fix memory leak of gpio_regmap structure [ Upstream commit 3bd44edd6c55828fd4e11cb0efce5b7160bfa2de ] The gpio_regmap structure is leaked on the error path. Fix this by jumping to the appropriate kfree instead of returning directly. Fixes: db305161880a ("gpio: regmap: Allow ngpio to be read from the property") Signed-off-by: Ioana Ciornei Suggested-by: Michael Walle Reviewed-by: Michael Walle Link: https://lore.kernel.org/r/20250922142427.3310221-7-ioana.ciornei@nxp.com Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c index 87c4225784cfa..b3b84a404485e 100644 --- a/drivers/gpio/gpio-regmap.c +++ b/drivers/gpio/gpio-regmap.c @@ -274,7 +274,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config if (!chip->ngpio) { ret = gpiochip_get_ngpios(chip, chip->parent); if (ret) - return ERR_PTR(ret); + goto err_free_gpio; } /* if not set, assume there is only one register */