loongarch.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Huacai Chen <chenhuacai@kernel.org>
To: Li Jun <lijun01@kylinos.cn>
Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] LoongArch: env: fix missing NULL checks for kstrdup
Date: Fri, 20 Mar 2026 11:29:13 +0800	[thread overview]
Message-ID: <CAAhV-H7mcb5sMCVH7Yf37cKOkXaPW1h5gZEndhyprZiVqZ6H5Q@mail.gmail.com> (raw)
In-Reply-To: <20260320004725.1927073-1-lijun01@kylinos.cn>

Hi, Jun,

What are you doing? In your understanding, my comments in V3 meant to
tell you to go back to V2?

Huacai

On Fri, Mar 20, 2026 at 8:48 AM Li Jun <lijun01@kylinos.cn> wrote:
>
> Fixes potential kernel oops during early boot when memory
> allocation fails while parsing CPU model from device tree.
> before return -ENOMEM, of_node_put(root) first.
>
> Signed-off-by: Li Jun <lijun01@kylinos.cn>
> ---
>  arch/loongarch/kernel/env.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/arch/loongarch/kernel/env.c b/arch/loongarch/kernel/env.c
> index 841206fde3ab..c586de80027c 100644
> --- a/arch/loongarch/kernel/env.c
> +++ b/arch/loongarch/kernel/env.c
> @@ -49,6 +49,10 @@ static int __init init_cpu_fullname(void)
>         ret = of_property_read_string(root, "model", &model);
>         if (ret == 0) {
>                 cpuname = kstrdup(model, GFP_KERNEL);
> +               if (!cpuname) {
> +                       of_node_put(root);
> +                       return -ENOMEM;
> +               }
>                 loongson_sysconf.cpuname = strsep(&cpuname, " ");
>         }
>         of_node_put(root);
> --
> 2.25.1
>

  reply	other threads:[~2026-03-20  3:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20  0:47 [PATCH v4] LoongArch: env: fix missing NULL checks for kstrdup Li Jun
2026-03-20  3:29 ` Huacai Chen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-03-20  5:39 Li Jun
2026-03-26  2:50 ` Huacai Chen

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=CAAhV-H7mcb5sMCVH7Yf37cKOkXaPW1h5gZEndhyprZiVqZ6H5Q@mail.gmail.com \
    --to=chenhuacai@kernel.org \
    --cc=lijun01@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).