* [PATCH] MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init()
@ 2020-01-10 1:30 Tiezhu Yang
2020-01-13 19:10 ` Paul Burton
0 siblings, 1 reply; 2+ messages in thread
From: Tiezhu Yang @ 2020-01-10 1:30 UTC (permalink / raw)
To: Paul Burton, Ralf Baechle, Huacai Chen, Jiaxun Yang
Cc: linux-mips, linux-kernel
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@loongson.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init()
2020-01-10 1:30 [PATCH] MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init() Tiezhu Yang
@ 2020-01-13 19:10 ` Paul Burton
0 siblings, 0 replies; 2+ messages in thread
From: Paul Burton @ 2020-01-13 19:10 UTC (permalink / raw)
To: Tiezhu Yang
Cc: Paul Burton, Ralf Baechle, Huacai Chen, Jiaxun Yang, linux-mips,
linux-kernel, linux-mips
Hello,
Tiezhu Yang wrote:
> If kzalloc fails, it should return -ENOMEM, otherwise may trigger a NULL
> pointer dereference.
Applied to mips-next.
> commit 72d052e28d1d
> https://git.kernel.org/mips/c/72d052e28d1d
>
> Fixes: 3adeb2566b9b ("MIPS: Loongson: Improve LEFI firmware interface")
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> Signed-off-by: Paul Burton <paulburton@kernel.org>
Thanks,
Paul
[ This message was auto-generated; if you believe anything is incorrect
then please email paulburton@kernel.org to report it. ]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-13 19:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 1:30 [PATCH] MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init() Tiezhu Yang
2020-01-13 19:10 ` Paul Burton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).