[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240225060401.52768-1-duoming@zju.edu.cn>
Date: Sun, 25 Feb 2024 14:04:01 +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] ARM: mvebu: Prevent null pointer dereference caused by kzalloc failure
The kzalloc() in i2c_quirk() will return null if the physical
memory has run out. As a result, if we dereference the new_compat
pointer, the null pointer dereference bug will happen.
This patch adds a check to avoid null pointer dereference.
Fixes: 5fd62066d290 ("ARM: mvebu: Add thermal quirk for the Armada 375 DB board")
Signed-off-by: Duoming Zhou <duoming@....edu.cn>
---
arch/arm/mach-mvebu/board-v7.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
index fd5d0c8ff69..7d2cb12e349 100644
--- a/arch/arm/mach-mvebu/board-v7.c
+++ b/arch/arm/mach-mvebu/board-v7.c
@@ -125,6 +125,8 @@ static void __init i2c_quirk(void)
struct property *new_compat;
new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL);
+ if (!new_compat)
+ continue;
new_compat->name = kstrdup("compatible", GFP_KERNEL);
new_compat->length = sizeof("marvell,mv78230-a0-i2c");
--
2.17.1
Powered by blists - more mailing lists