Skip to content

Commit 7a648d5

Browse files
outman119linusw
authored andcommitted
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. Fixes: 90a18c5 ("pinctrl: pinconf-generic: Handle string values for generic properties") Signed-off-by: Felix Gu <ustc.gu@gmail.com> Reviewed-by: Antonio Borneo <antonio.borneo@foss.st.com> Signed-off-by: Linus Walleij <linusw@kernel.org>
1 parent 09a30b7 commit 7a648d5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/pinctrl/pinconf-generic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,13 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
351351

352352
ret = parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
353353
if (ret)
354-
return ret;
354+
goto out;
355355
if (pctldev && pctldev->desc->num_custom_params &&
356356
pctldev->desc->custom_params) {
357357
ret = parse_dt_cfg(np, pctldev->desc->custom_params,
358358
pctldev->desc->num_custom_params, cfg, &ncfg);
359359
if (ret)
360-
return ret;
360+
goto out;
361361
}
362362

363363
/* no configs found at all */

0 commit comments

Comments
 (0)