pinctrl: pinconf-generic: Fix memory leak in pinconf_generic_parse_dt_config()
Subsystems (2)
PATCH 1/1 pinctrl: pinconf-generic: Fix memory leak in pinconf_generic_parse_dt_config()
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.
--- drivers/pinctrl/pinconf-generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/pinconf-generic.c +2 -2
@@ -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,
Signature · 1 line
Felix Gu <[email protected]>
Quoted 34 lines · Felix Gu
In
pinconf_generic_parse_dt_config(), ifparse_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 <[email protected]>---
drivers/pinctrl/pinconf-generic.c | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/pinctrl/pinconf-generic.c +0
-0@@ -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 */
Quoted 5 lines
---
base-commit:635c467cc14ebdffab3f77610217c1dacaf88e8c
change-id: 20260214-pinconf-cbc1e31088ffBest regards,
Thanks!
Antonio
Linus Walleij
maintainerQuoted 9 lines · Felix Gu
In
pinconf_generic_parse_dt_config(), ifparse_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 <[email protected]>
Patch applied for fixes.
Yours,
Linus Walleij