Skip to contentSkip to conversation

pd: fix resource deallocation on error path

PATCH New Vladimir Zapolskiy 2 participants 5 messages Jul 31, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover pd: fix resource deallocation on error path

The first change fixes a bug introduced by 2be2a3ff42a5, memory allocated by kstrdup_const() must be always deallocated with kfree_const(), otherwise there is a risk of kfree'ing ro memory.

The second change removes double of_node_put(), if for_each_compatible_node() body execution is not terminated. This prevents from object refcounter overflow over zero in OF_DYNAMIC build.

Vladimir Zapolskiy (2):
ARM: EXYNOS: pd: fix potentian kfree() of ro memory
ARM: EXYNOS: fix double of_node_put() on error path

 arch/arm/mach-exynos/pm_domains.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/2 ARM: EXYNOS: pd: fix potentian kfree() of ro memory

The change fixes a bug introduced by 2be2a3ff42a5, memory allocated by kstrdup_const() must be always deallocated with kfree_const(), otherwise there is a risk of kfree'ing ro memory.

Fixes 2be2a3ff42a5 ("ARM: EXYNOS: register power domain driver from core_initcall")

---
Changes from v1 to v2:
* split a single change v1 into two
* added Fixes tag and Cc: <[email protected]>

 arch/arm/mach-exynos/pm_domains.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-exynos/pm_domains.c +1 -1
index 6001f1c..5121baa 100644
@@ -146,7 +146,7 @@ static __init int exynos4_pm_init_power_domain(void)
 		pd->base = of_iomap(np, 0);
 		if (!pd->base) {
 			pr_warn("%s: failed to map memory\n", __func__);
-			kfree(pd->pd.name);
+			kfree_const(pd->pd.name);
 			kfree(pd);
 			of_node_put(np);
 			continue;
Signature · 1 line
2.1.4
#2 lore raw

PATCH v2 1/2 ARM: EXYNOS: pd: fix potentian kfree() of ro memory

Quoted 7 lines · Vladimir Zapolskiy

The change fixes a bug introduced by 2be2a3ff42a5, memory allocated by kstrdup_const() must be always deallocated with kfree_const(), otherwise there is a risk of kfree'ing ro memory.

Fixes 2be2a3ff42a5 ("ARM: EXYNOS: register power domain driver from core_initcall")
Quoted 7 lines

---
Changes from v1 to v2:
* split a single change v1 into two
* added Fixes tag and Cc: <[email protected]>

 arch/arm/mach-exynos/pm_domains.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Best regards,
Krzysztof

#3 lore raw

PATCH v2 2/2 ARM: EXYNOS: fix double of_node_put() on error path

In reply to Vladimir Zapolskiy

The change removes the second of_node_put(), if for_each_compatible_node() body execution is not terminated. This prevents from object refcounter overflow over zero in OF_DYNAMIC build.

---
Changes from v1 to v2:
* split a single change v1 into two

 arch/arm/mach-exynos/pm_domains.c | 1 -
 1 file changed, 1 deletion(-)
arch/arm/mach-exynos/pm_domains.c +0 -1
index 5121baa..4a87e86 100644
@@ -148,7 +148,6 @@ static __init int exynos4_pm_init_power_domain(void)
 			pr_warn("%s: failed to map memory\n", __func__);
 			kfree_const(pd->pd.name);
 			kfree(pd);
-			of_node_put(np);
 			continue;
 		}
 
Signature · 1 line
2.1.4
#4 lore raw

PATCH v2 2/2 ARM: EXYNOS: fix double of_node_put() on error path

Quoted 5 lines · Vladimir Zapolskiy

The change removes the second of_node_put(), if for_each_compatible_node() body execution is not terminated. This prevents from object refcounter overflow over zero in OF_DYNAMIC build.

Quoted 8 lines

---
Changes from v1 to v2:
* split a single change v1 into two

 arch/arm/mach-exynos/pm_domains.c | 1 -
 1 file changed, 1 deletion(-)

Best regards,
Krzysztof