All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: syscon: Don't free allocated name for regmap_config
@ 2020-09-03 16:02 ` Marc Zyngier
  0 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2020-09-03 16:02 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Lee Jones, Arnd Bergmann, Suman Anna, kernel-team

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 occured.

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

Fixes: e15d7f2b81d2 ("mfd: syscon: Use a unique name with regmap_config")
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/mfd/syscon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 75859e492984..7a660411c562 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -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);
@@ -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);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-02-16  8:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03 16:02 [PATCH] mfd: syscon: Don't free allocated name for regmap_config Marc Zyngier
2020-09-03 16:02 ` Marc Zyngier
2020-09-08  8:22 ` Lee Jones
2020-09-08  8:22   ` Lee Jones
2020-09-24 12:39 ` Lee Jones
2020-09-24 12:39   ` Lee Jones
2020-09-26  0:28   ` Suman Anna
2020-09-26  0:28     ` Suman Anna
2020-09-28  9:19     ` Lee Jones
2020-09-28  9:19       ` Lee Jones
2021-02-16  6:34 ` Tomi Valkeinen
2021-02-16  6:34   ` Tomi Valkeinen
2021-02-16  8:42   ` Marc Zyngier
2021-02-16  8:42     ` Marc Zyngier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.