projects/linux·commit 3bd44edd

gpio: regmap: fix memory leak of gpio_regmap structure

3bd44edd · Ioana Ciornei <[email protected]> · 2025-09-22 17:24:21 +03:00

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 <[email protected]>
Suggested-by: Michael Walle <[email protected]>
Reviewed-by: Michael Walle <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Bartosz Golaszewski <[email protected]>
Commit
3bd44edd6c55828fd4e11cb0efce5b7160bfa2de
Parents
c6ccc4dd

Changes

1 files changed · +1 −1

FileStatusAddDelContent
drivers/gpio/gpio-regmap.cmodified+1−1View file

drivers/gpio/gpio-regmap.c

View file
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index e8a32df..3f8b723 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 */