[PATCH] arm: mach: fix missing NULL checks and memory leaks in DT property setup

Li Jun posted 1 patch 1 week, 5 days ago
arch/arm/mach-mvebu/coherency.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] arm: mach: fix missing NULL checks and memory leaks in DT property setup
Posted by Li Jun 1 week, 5 days ago
Check kstrdup returns, free p on failure.

Signed-off-by: Li Jun <lijun01@kylinos.cn>
---
 arch/arm/mach-mvebu/coherency.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
index 7234d487ff39..aa09a829b1db 100644
--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -192,6 +192,10 @@ static void __init armada_375_380_coherency_init(struct device_node *np)
 
 		p = kzalloc_obj(*p);
 		p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
+		if (!p->name) {
+			kfree(p);
+			return;
+		}
 		of_add_property(cache_dn, p);
 	}
 }
-- 
2.25.1