linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: mvebu: Add check in coherency.c to prevent null pointer dereference
@ 2024-02-25  6:04 Duoming Zhou
  2024-02-25 11:30 ` Russell King (Oracle)
  2024-02-26 13:39 ` Andrew Lunn
  0 siblings, 2 replies; 5+ messages in thread
From: Duoming Zhou @ 2024-02-25  6:04 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-kernel, andrew, gregory.clement, sebastian.hesselbarth,
	linux, Duoming Zhou

The kzalloc() in armada_375_380_coherency_init() will return
null if the physical memory has run out. As a result, if we
dereference the property pointer, the null pointer dereference
bug will happen.

This patch adds a check to avoid null pointer dereference.

Fixes: 497a92308af8 ("ARM: mvebu: implement L2/PCIe deadlock workaround")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
 arch/arm/mach-mvebu/coherency.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
index a6b621ff0b8..a81a3c8c19a 100644
--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -191,6 +191,8 @@ static void __init armada_375_380_coherency_init(struct device_node *np)
 		struct property *p;
 
 		p = kzalloc(sizeof(*p), GFP_KERNEL);
+		if (!p)
+			continue;
 		p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
 		of_add_property(cache_dn, p);
 	}
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2024-02-26 14:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-25  6:04 [PATCH] ARM: mvebu: Add check in coherency.c to prevent null pointer dereference Duoming Zhou
2024-02-25 11:30 ` Russell King (Oracle)
2024-02-25 13:20   ` duoming
2024-02-26 13:39 ` Andrew Lunn
2024-02-26 14:08   ` Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).