[PATCH v2] arm: mvebu: fix null pointer when access

Li Jun posted 1 patch 2 weeks, 5 days ago
There is a newer version of this series
arch/arm/mach-mvebu/coherency.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH v2] arm: mvebu: fix null pointer when access
Posted by Li Jun 2 weeks, 5 days ago
the kzalloc&kstrdup may return null pointer, will cause kernel panic.

-Fix null pointer.

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

diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
index a6b621ff0b87..f9411e16ddbb 100644
--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -191,7 +191,13 @@ static void __init armada_375_380_coherency_init(struct device_node *np)
 		struct property *p;
 
 		p = kzalloc(sizeof(*p), GFP_KERNEL);
+		if (!p)
+			return;
 		p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
+		if (!p->name) {
+			kfree(p);
+			return;
+		}
 		of_add_property(cache_dn, p);
 	}
 }
-- 
2.25.1
Re: [PATCH v2] arm: mvebu: fix null pointer when access
Posted by Andrew Lunn 2 weeks, 5 days ago
On Wed, Mar 18, 2026 at 04:21:43PM +0800, Li Jun wrote:
> the kzalloc&kstrdup may return null pointer, will cause kernel panic.
> 
> -Fix null pointer.

Please don't post new versions of a patch within 24 hours. You need to
give reviewers time to actually review.

Please look at my comments to v1.

       Andrew