From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Liao Chang <liaochang1@huawei.com>
Cc: chenhuacai@kernel.org, jiaxun.yang@flygoat.com,
tangyouling@loongson.cn, hejinyang@loongson.cn,
linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: Loongson64: Add WARN_ON on kexec related kmalloc failed
Date: Fri, 11 Nov 2022 16:03:51 +0100 [thread overview]
Message-ID: <20221111150351.GB13465@alpha.franken.de> (raw)
In-Reply-To: <20221103011815.139424-1-liaochang1@huawei.com>
On Thu, Nov 03, 2022 at 09:18:15AM +0800, Liao Chang wrote:
> Add WARN_ON on kexec related kmalloc failed, avoid to pass NULL pointer
> to following memcpy and loongson_kexec_prepare.
>
> Fixes: 6ce48897ce47 ("MIPS: Loongson64: Add kexec/kdump support")
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> ---
> arch/mips/loongson64/reset.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/arch/mips/loongson64/reset.c b/arch/mips/loongson64/reset.c
> index 758d5d26aaaa..e420800043b0 100644
> --- a/arch/mips/loongson64/reset.c
> +++ b/arch/mips/loongson64/reset.c
> @@ -16,6 +16,7 @@
> #include <asm/bootinfo.h>
> #include <asm/idle.h>
> #include <asm/reboot.h>
> +#include <asm/bug.h>
>
> #include <loongson.h>
> #include <boot_param.h>
> @@ -159,8 +160,17 @@ static int __init mips_reboot_setup(void)
>
> #ifdef CONFIG_KEXEC
> kexec_argv = kmalloc(KEXEC_ARGV_SIZE, GFP_KERNEL);
> + if (WARN_ON(!kexec_argv))
> + return -ENOMEM;
> +
> kdump_argv = kmalloc(KEXEC_ARGV_SIZE, GFP_KERNEL);
> + if (WARN_ON(!kdump_argv))
> + return -ENOMEM;
> +
> kexec_envp = kmalloc(KEXEC_ENVP_SIZE, GFP_KERNEL);
> + if (WARN_ON(!kexec_envp))
> + return -ENOMEM;
> +
> fw_arg1 = KEXEC_ARGV_ADDR;
> memcpy(kexec_envp, (void *)fw_arg2, KEXEC_ENVP_SIZE);
>
> --
> 2.17.1
applied to mips-fixes.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
prev parent reply other threads:[~2022-11-11 15:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 1:18 Liao Chang
2022-11-11 15:03 ` Thomas Bogendoerfer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221111150351.GB13465@alpha.franken.de \
--to=tsbogend@alpha.franken.de \
--cc=chenhuacai@kernel.org \
--cc=hejinyang@loongson.cn \
--cc=jiaxun.yang@flygoat.com \
--cc=liaochang1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=tangyouling@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®