Skip to content

Commit

Permalink
mfd: syscon: Don't free allocated name for regmap_config
Browse files Browse the repository at this point in the history
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: e15d7f2 ("mfd: syscon: Use a unique name with regmap_config")
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
  • Loading branch information
Marc Zyngier authored and Lee Jones committed Sep 30, 2020
1 parent 05027df commit 529a110
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mfd/syscon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

0 comments on commit 529a110

Please sign in to comment.