[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1578619842-926-1-git-send-email-yangtiezhu@loongson.cn>
Date: Fri, 10 Jan 2020 09:30:42 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Paul Burton <paulburton@...nel.org>,
Ralf Baechle <ralf@...ux-mips.org>,
Huacai Chen <chenhc@...ote.com>,
Jiaxun Yang <jiaxun.yang@...goat.com>
Cc: linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init()
If kzalloc fails, it should return -ENOMEM, otherwise may trigger a NULL
pointer dereference.
Fixes: 3adeb2566b9b ("MIPS: Loongson: Improve LEFI firmware interface")
Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
arch/mips/loongson64/platform.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/mips/loongson64/platform.c b/arch/mips/loongson64/platform.c
index 13f3404..9674ae1 100644
--- a/arch/mips/loongson64/platform.c
+++ b/arch/mips/loongson64/platform.c
@@ -27,6 +27,9 @@ static int __init loongson3_platform_init(void)
continue;
pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
+ if (!pdev)
+ return -ENOMEM;
+
pdev->name = loongson_sysconf.sensors[i].name;
pdev->id = loongson_sysconf.sensors[i].id;
pdev->dev.platform_data = &loongson_sysconf.sensors[i];
--
2.1.0
Powered by blists - more mailing lists