mfd: syscon: Don't free allocated name for regmap_config

The name allocated for the regmap_config structure is freed
pretty early, right after the registration of the MMIO region.

Unfortunately, that doesn't follow the life cycle that debugfs
expects, as it can access the name field long after the free
has occurred.

Move the free on the error path, and keep it forever otherwise.

Fixes: e15d7f2b81 ("mfd: syscon: Use a unique name with regmap_config")
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
Marc Zyngier 2020-09-03 17:02:37 +01:00 committed by Lee Jones
parent 05027df1b9
commit 529a110121
1 changed files with 1 additions and 1 deletions

View File

@ -108,7 +108,6 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
syscon_config.max_register = resource_size(&res) - reg_io_width; syscon_config.max_register = resource_size(&res) - reg_io_width;
regmap = regmap_init_mmio(NULL, base, &syscon_config); regmap = regmap_init_mmio(NULL, base, &syscon_config);
kfree(syscon_config.name);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
pr_err("regmap init failed\n"); pr_err("regmap init failed\n");
ret = PTR_ERR(regmap); ret = PTR_ERR(regmap);
@ -145,6 +144,7 @@ err_clk:
regmap_exit(regmap); regmap_exit(regmap);
err_regmap: err_regmap:
iounmap(base); iounmap(base);
kfree(syscon_config.name);
err_map: err_map:
kfree(syscon); kfree(syscon);
return ERR_PTR(ret); return ERR_PTR(ret);