public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Binbin Zhou <zhoubb.aaron@gmail.com>,
	Binbin Zhou <zhoubinbin@loongson.cn>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Michael Turquette <mturquette@baylibre.com>,
	Yinbo Zhu <zhuyinbo@loongson.cn>
Cc: Huacai Chen <chenhuacai@kernel.org>,
	linux-clk@vger.kernel.org, Xuerui Wang <kernel@xen0n.name>,
	loongarch@lists.linux.dev, Binbin Zhou <zhoubinbin@loongson.cn>,
	stable@vger.kernel.org,
	Gustavo A . R . Silva <gustavoars@kernel.org>
Subject: Re: [PATCH v2] clk: clk-loongson2: Fix the number count of clk provider
Date: Mon, 13 Jan 2025 10:50:38 -0800	[thread overview]
Message-ID: <ba25dfc40e9ae91205d61c838e368490.sboyd@kernel.org> (raw)
In-Reply-To: <20250109113004.2473331-1-zhoubinbin@loongson.cn>

Quoting Binbin Zhou (2025-01-09 03:30:04)
> diff --git a/drivers/clk/clk-loongson2.c b/drivers/clk/clk-loongson2.c
> index 6bf51d5a49a1..9c240a2308f5 100644
> --- a/drivers/clk/clk-loongson2.c
> +++ b/drivers/clk/clk-loongson2.c
> @@ -294,7 +294,7 @@ static int loongson2_clk_probe(struct platform_device *pdev)
>                 return -EINVAL;
>  
>         for (p = data; p->name; p++)
> -               clks_num++;
> +               clks_num = max(clks_num, p->id + 1);
>  
>         clp = devm_kzalloc(dev, struct_size(clp, clk_data.hws, clks_num),
>                            GFP_KERNEL);
> @@ -309,6 +309,9 @@ static int loongson2_clk_probe(struct platform_device *pdev)
>         clp->clk_data.num = clks_num;
>         clp->dev = dev;
>  
> +       /* Avoid returning NULL for unused id */
> +       memset_p((void **)&clp->clk_data.hws, ERR_PTR(-ENOENT), clks_num);

This looks wrong. It's already an array of pointers, i.e. the type is
'struct clk_hw *[]' or 'struct clk_hw **' so we shouldn't need to take
the address of it. Should it be

	memset_p((void **)clkp->clk_data.hws, ERR_PTR(-ENOENT), clks_num);

? It's unfortunate that we have to cast here, but I guess this is the
best way we can indicate that the type should be an array of pointers.

  reply	other threads:[~2025-01-13 18:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 11:30 [PATCH v2] clk: clk-loongson2: Fix the number count of clk provider Binbin Zhou
2025-01-13 18:50 ` Stephen Boyd [this message]
2025-01-14 12:53   ` Binbin Zhou

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=ba25dfc40e9ae91205d61c838e368490.sboyd@kernel.org \
    --to=sboyd@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=gustavoars@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-clk@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=mturquette@baylibre.com \
    --cc=stable@vger.kernel.org \
    --cc=zhoubb.aaron@gmail.com \
    --cc=zhoubinbin@loongson.cn \
    --cc=zhuyinbo@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