linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Duoming Zhou <duoming@zju.edu.cn>, linux-kernel@vger.kernel.org
Cc: mturquette@baylibre.com, michal.simek@amd.com,
	linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Duoming Zhou <duoming@zju.edu.cn>
Subject: Re: [PATCH] clk: zynq: Prevent null pointer dereference caused by kmalloc failure
Date: Wed, 28 Feb 2024 15:07:05 -0800	[thread overview]
Message-ID: <f0a90f14993aa0fddb87e658be43341b.sboyd@kernel.org> (raw)
In-Reply-To: <20240214073318.82573-1-duoming@zju.edu.cn>

Quoting Duoming Zhou (2024-02-13 23:33:18)
> diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
> index 7bdeaff2bfd..7621c2f0046 100644
> --- a/drivers/clk/zynq/clkc.c
> +++ b/drivers/clk/zynq/clkc.c
> @@ -427,7 +427,7 @@ static void __init zynq_clk_setup(struct device_node *np)
>                         SLCR_GEM1_CLK_CTRL, 0, 0, &gem1clk_lock);
>  
>         tmp = strlen("mio_clk_00x");
> -       clk_name = kmalloc(tmp, GFP_KERNEL);
> +       clk_name = kmalloc(tmp, GFP_KERNEL | __GFP_NOFAIL);

Just make a stack variable please. __GFP_NOFAIL is a bad code smell.

>         for (i = 0; i < NUM_MIO_PINS; i++) {
>                 int idx;
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      parent reply	other threads:[~2024-02-28 23:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14  7:33 [PATCH] clk: zynq: Prevent null pointer dereference caused by kmalloc failure Duoming Zhou
2024-02-19 13:35 ` Michal Simek
2024-02-28 23:07 ` Stephen Boyd [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=f0a90f14993aa0fddb87e658be43341b.sboyd@kernel.org \
    --to=sboyd@kernel.org \
    --cc=duoming@zju.edu.cn \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=mturquette@baylibre.com \
    /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 NNTP newsgroup(s).