Commit 72d052e2 authored by Tiezhu Yang's avatar Tiezhu Yang Committed by Paul Burton

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: 3adeb256 ("MIPS: Loongson: Improve LEFI firmware interface")
Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: default avatarPaul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Huacai Chen <chenhc@lemote.com>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
parent 23c25c73
...@@ -27,6 +27,9 @@ static int __init loongson3_platform_init(void) ...@@ -27,6 +27,9 @@ static int __init loongson3_platform_init(void)
continue; continue;
pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL); pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
if (!pdev)
return -ENOMEM;
pdev->name = loongson_sysconf.sensors[i].name; pdev->name = loongson_sysconf.sensors[i].name;
pdev->id = loongson_sysconf.sensors[i].id; pdev->id = loongson_sysconf.sensors[i].id;
pdev->dev.platform_data = &loongson_sysconf.sensors[i]; pdev->dev.platform_data = &loongson_sysconf.sensors[i];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment