[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240225143122.5640-1-duoming@zju.edu.cn>
Date: Sun, 25 Feb 2024 22:31:22 +0800
From: Duoming Zhou <duoming@....edu.cn>
To: linux-arm-kernel@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org,
andrew@...n.ch,
gregory.clement@...tlin.com,
sebastian.hesselbarth@...il.com,
linux@...linux.org.uk,
Duoming Zhou <duoming@....edu.cn>
Subject: [PATCH v2] ARM: mvebu: Add error handling in coherency.c to prevent bugs
The kzalloc() and kstrdup() in armada_375_380_coherency_init()
will return null if the physical memory has run out. As a result,
if we dereference these null pointers, the null pointer dereference
bugs will happen.
This patch adds error handling to avoid null pointer dereference.
Fixes: 497a92308af8 ("ARM: mvebu: implement L2/PCIe deadlock workaround")
Signed-off-by: Duoming Zhou <duoming@....edu.cn>
---
Changes in v2:
- Adds checks to judge whether kstrdup() fails.
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 a6b621ff0b8..be50c83bfef 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)
+ continue;
p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
+ if (!p->name) {
+ kfree(p);
+ continue;
+ }
of_add_property(cache_dn, p);
}
}
--
2.17.1
Powered by blists - more mailing lists