Commit 7a648d59 authored by Felix Gu's avatar Felix Gu Committed by Linus Walleij
Browse files

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: 90a18c51 ("pinctrl: pinconf-generic: Handle string values for generic properties")
Signed-off-by: default avatarFelix Gu <ustc.gu@gmail.com>
Reviewed-by: default avatarAntonio Borneo <antonio.borneo@foss.st.com>
Signed-off-by: default avatarLinus Walleij <linusw@kernel.org>
parent 09a30b7a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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 */