stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@dabbelt.com>
To: vincent.chen@sifive.com
Cc: mturquette@baylibre.com, sboyd@kernel.org,
	Paul Walmsley <paul.walmsley@sifive.com>,
	linux-riscv@lists.infradead.org, schwab@suse.de,
	vincent.chen@sifive.com, stable@vger.kernel.org
Subject: Re: [PATCH] clk: sifive: allocate sufficient memory for struct __prci_data
Date: Thu, 25 Jun 2020 15:13:39 -0700 (PDT)	[thread overview]
Message-ID: <mhng-af462151-9be0-44c9-aeca-7777d4040d72@palmerdabbelt-glaptop1> (raw)
In-Reply-To: <1592875458-5887-1-git-send-email-vincent.chen@sifive.com>

On Mon, 22 Jun 2020 18:24:17 PDT (-0700), vincent.chen@sifive.com wrote:
> The (struct __prci_data).hw_clks.hws is an array with dynamic elements.
> Using struct_size(pd, hw_clks.hws, ARRAY_SIZE(__prci_init_clocks))
> instead of sizeof(*pd) to get the correct memory size of
> struct __prci_data for sifive/fu540-prci. After applying this
> modifications, the kernel runs smoothly with CONFIG_SLAB_FREELIST_RANDOM
> enabled on the HiFive unleashed board.
>
> Fixes: 30b8e27e3b58 ("clk: sifive: add a driver for the SiFive FU540 PRCI IP block")
> Cc: stable@vger.kernel.org
> Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
> ---
>  drivers/clk/sifive/fu540-prci.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/sifive/fu540-prci.c b/drivers/clk/sifive/fu540-prci.c
> index 6282ee2f361c..a8901f90a61a 100644
> --- a/drivers/clk/sifive/fu540-prci.c
> +++ b/drivers/clk/sifive/fu540-prci.c
> @@ -586,7 +586,10 @@ static int sifive_fu540_prci_probe(struct platform_device *pdev)
>  	struct __prci_data *pd;
>  	int r;
>
> -	pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
> +	pd = devm_kzalloc(dev,
> +			  struct_size(pd, hw_clks.hws,
> +				      ARRAY_SIZE(__prci_init_clocks)),
> +			  GFP_KERNEL);
>  	if (!pd)
>  		return -ENOMEM;

This is on fixes, thanks!

  reply	other threads:[~2020-06-25 22:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  1:24 [PATCH] clk: sifive: allocate sufficient memory for struct __prci_data Vincent Chen
2020-06-25 22:13 ` Palmer Dabbelt [this message]
2020-06-29 23:23   ` Stephen Boyd
2020-06-29 23:34     ` Palmer Dabbelt
2020-06-29 23:37       ` Stephen Boyd

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=mhng-af462151-9be0-44c9-aeca-7777d4040d72@palmerdabbelt-glaptop1 \
    --to=palmer@dabbelt.com \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mturquette@baylibre.com \
    --cc=paul.walmsley@sifive.com \
    --cc=sboyd@kernel.org \
    --cc=schwab@suse.de \
    --cc=stable@vger.kernel.org \
    --cc=vincent.chen@sifive.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).