Skip to content

Commit fa70692

Browse files
Liao Changtsbogend
authored andcommitted
MIPS: Loongson64: Add WARN_ON on kexec related kmalloc failed
Add WARN_ON on kexec related kmalloc failed, avoid to pass NULL pointer to following memcpy and loongson_kexec_prepare. Fixes: 6ce4889 ("MIPS: Loongson64: Add kexec/kdump support") Signed-off-by: Liao Chang <liaochang1@huawei.com> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent 612d807 commit fa70692

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/mips/loongson64/reset.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <asm/bootinfo.h>
1717
#include <asm/idle.h>
1818
#include <asm/reboot.h>
19+
#include <asm/bug.h>
1920

2021
#include <loongson.h>
2122
#include <boot_param.h>
@@ -159,8 +160,17 @@ static int __init mips_reboot_setup(void)
159160

160161
#ifdef CONFIG_KEXEC
161162
kexec_argv = kmalloc(KEXEC_ARGV_SIZE, GFP_KERNEL);
163+
if (WARN_ON(!kexec_argv))
164+
return -ENOMEM;
165+
162166
kdump_argv = kmalloc(KEXEC_ARGV_SIZE, GFP_KERNEL);
167+
if (WARN_ON(!kdump_argv))
168+
return -ENOMEM;
169+
163170
kexec_envp = kmalloc(KEXEC_ENVP_SIZE, GFP_KERNEL);
171+
if (WARN_ON(!kexec_envp))
172+
return -ENOMEM;
173+
164174
fw_arg1 = KEXEC_ARGV_ADDR;
165175
memcpy(kexec_envp, (void *)fw_arg2, KEXEC_ENVP_SIZE);
166176

0 commit comments

Comments
 (0)