drivers/pinctrl/pinconf-generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
In pinconf_generic_parse_dt_config(), if parse_dt_cfg() fails, it returns
directly. This bypasses the cleanup logic and results in a memory leak of
the cfg buffer.
Fix this by jumping to the out label on failure, ensuring kfree(cfg) is
called before returning.
Fixes: 90a18c512884 ("pinctrl: pinconf-generic: Handle string values for generic properties")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/pinctrl/pinconf-generic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index 94b1d057197c..2b030bd0e6ad 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -351,13 +351,13 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
ret = parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
if (ret)
- return ret;
+ goto out;
if (pctldev && pctldev->desc->num_custom_params &&
pctldev->desc->custom_params) {
ret = parse_dt_cfg(np, pctldev->desc->custom_params,
pctldev->desc->num_custom_params, cfg, &ncfg);
if (ret)
- return ret;
+ goto out;
}
/* no configs found at all */
---
base-commit: 635c467cc14ebdffab3f77610217c1dacaf88e8c
change-id: 20260214-pinconf-cbc1e31088ff
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
On Sat, Feb 14, 2026 at 4:14 PM Felix Gu <ustc.gu@gmail.com> wrote:
> In pinconf_generic_parse_dt_config(), if parse_dt_cfg() fails, it returns
> directly. This bypasses the cleanup logic and results in a memory leak of
> the cfg buffer.
>
> Fix this by jumping to the out label on failure, ensuring kfree(cfg) is
> called before returning.
>
> Fixes: 90a18c512884 ("pinctrl: pinconf-generic: Handle string values for generic properties")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Patch applied for fixes.
Yours,
Linus Walleij
On Sat, 2026-02-14 at 23:14 +0800, Felix Gu wrote:
> In pinconf_generic_parse_dt_config(), if parse_dt_cfg() fails, it returns
> directly. This bypasses the cleanup logic and results in a memory leak of
> the cfg buffer.
>
> Fix this by jumping to the out label on failure, ensuring kfree(cfg) is
> called before returning.
>
> Fixes: 90a18c512884 ("pinctrl: pinconf-generic: Handle string values for generic properties")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
> drivers/pinctrl/pinconf-generic.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
> index 94b1d057197c..2b030bd0e6ad 100644
> --- a/drivers/pinctrl/pinconf-generic.c
> +++ b/drivers/pinctrl/pinconf-generic.c
> @@ -351,13 +351,13 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
>
> ret = parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
> if (ret)
> - return ret;
> + goto out;
> if (pctldev && pctldev->desc->num_custom_params &&
> pctldev->desc->custom_params) {
> ret = parse_dt_cfg(np, pctldev->desc->custom_params,
> pctldev->desc->num_custom_params, cfg, &ncfg);
> if (ret)
> - return ret;
> + goto out;
> }
>
> /* no configs found at all */
>
> ---
> base-commit: 635c467cc14ebdffab3f77610217c1dacaf88e8c
> change-id: 20260214-pinconf-cbc1e31088ff
>
> Best regards,
Reviewed-by: Antonio Borneo <antonio.borneo@foss.st.com>
Thanks!
Antonio
© 2016 - 2026 Red Hat, Inc.