mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init()
[ Upstream commit72d052e28d] If kzalloc fails, it should return -ENOMEM, otherwise may trigger a NULL pointer dereference. Fixes:3adeb2566b("MIPS: Loongson: Improve LEFI firmware interface") Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Paul 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 Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cf8938b1dd
commit
2ebbbc9bf1
@@ -31,6 +31,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];
|
||||
|
||||
Reference in New Issue
Block a user