Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 90a18c512884 ("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>

authored by

Felix Gu and committed by
Linus Walleij
7a648d59 09a30b7a

+2 -2
+2 -2
drivers/pinctrl/pinconf-generic.c
··· 351 351 352 352 ret = parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg); 353 353 if (ret) 354 - return ret; 354 + goto out; 355 355 if (pctldev && pctldev->desc->num_custom_params && 356 356 pctldev->desc->custom_params) { 357 357 ret = parse_dt_cfg(np, pctldev->desc->custom_params, 358 358 pctldev->desc->num_custom_params, cfg, &ncfg); 359 359 if (ret) 360 - return ret; 360 + goto out; 361 361 } 362 362 363 363 /* no configs found at all */