stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: sifive: allocate sufficient memory for struct __prci_data
@ 2020-06-23  1:24 Vincent Chen
  2020-06-25 22:13 ` Palmer Dabbelt
  0 siblings, 1 reply; 5+ messages in thread
From: Vincent Chen @ 2020-06-23  1:24 UTC (permalink / raw)
  To: mturquette, sboyd, paul.walmsley, palmer
  Cc: linux-riscv, schwab, Vincent Chen, stable

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;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: sifive: allocate sufficient memory for struct __prci_data
  2020-06-23  1:24 [PATCH] clk: sifive: allocate sufficient memory for struct __prci_data Vincent Chen
@ 2020-06-25 22:13 ` Palmer Dabbelt
  2020-06-29 23:23   ` Stephen Boyd
  0 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2020-06-25 22:13 UTC (permalink / raw)
  To: vincent.chen
  Cc: mturquette, sboyd, Paul Walmsley, linux-riscv, schwab,
	vincent.chen, stable

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!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: sifive: allocate sufficient memory for struct __prci_data
  2020-06-25 22:13 ` Palmer Dabbelt
@ 2020-06-29 23:23   ` Stephen Boyd
  2020-06-29 23:34     ` Palmer Dabbelt
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2020-06-29 23:23 UTC (permalink / raw)
  To: Palmer Dabbelt, vincent.chen
  Cc: mturquette, Paul Walmsley, linux-riscv, schwab, vincent.chen, stable

Quoting Palmer Dabbelt (2020-06-25 15:13:39)
> 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!

Does that mean applied to sifive tree? I see it in next but only noticed
this by chance because it wasn't sent to the linux-clk mailing list.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: sifive: allocate sufficient memory for struct __prci_data
  2020-06-29 23:23   ` Stephen Boyd
@ 2020-06-29 23:34     ` Palmer Dabbelt
  2020-06-29 23:37       ` Stephen Boyd
  0 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2020-06-29 23:34 UTC (permalink / raw)
  To: sboyd
  Cc: vincent.chen, mturquette, Paul Walmsley, linux-riscv, schwab,
	vincent.chen, stable

On Mon, 29 Jun 2020 16:23:47 PDT (-0700), sboyd@kernel.org wrote:
> Quoting Palmer Dabbelt (2020-06-25 15:13:39)
>> 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!
>
> Does that mean applied to sifive tree? I see it in next but only noticed
> this by chance because it wasn't sent to the linux-clk mailing list.

Sorry, I was going a bit too fast and didn't realize this wasn't in arch/riscv/
so I didn't wait for an ack.  I put it on my fixes branch, which is what I sent
for the RCs.  That's merged into linux-next as well, as far as I understand
that's the normal way to do things.  It ended up in Linus' tree as d0a5fdf4cc83
("clk: sifive: allocate sufficient memory for struct __prci_data"), which is in
rc3.

We don't really have a SiFive tree, the SiFive stuff just goes in through the
RISC-V tree.  In theory I've been meaning to split them up for a while, but
given the maintainers are the same I just never got around to doing so.

LMK if I screwed something up.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: sifive: allocate sufficient memory for struct __prci_data
  2020-06-29 23:34     ` Palmer Dabbelt
@ 2020-06-29 23:37       ` Stephen Boyd
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2020-06-29 23:37 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: vincent.chen, mturquette, Paul Walmsley, linux-riscv, schwab,
	vincent.chen, stable

Quoting Palmer Dabbelt (2020-06-29 16:34:10)
> On Mon, 29 Jun 2020 16:23:47 PDT (-0700), sboyd@kernel.org wrote:
> >
> > Does that mean applied to sifive tree? I see it in next but only noticed
> > this by chance because it wasn't sent to the linux-clk mailing list.
> 
> Sorry, I was going a bit too fast and didn't realize this wasn't in arch/riscv/
> so I didn't wait for an ack.  I put it on my fixes branch, which is what I sent
> for the RCs.  That's merged into linux-next as well, as far as I understand
> that's the normal way to do things.  It ended up in Linus' tree as d0a5fdf4cc83
> ("clk: sifive: allocate sufficient memory for struct __prci_data"), which is in
> rc3.
> 
> We don't really have a SiFive tree, the SiFive stuff just goes in through the
> RISC-V tree.  In theory I've been meaning to split them up for a while, but
> given the maintainers are the same I just never got around to doing so.
> 
> LMK if I screwed something up.

No worries. I would have noticed this patch earlier if it had been sent
to the linux-clk mailing list which I use to catch patches that should
be reviewed for the clk tree. I'm not overly concerned. Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-29 23:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23  1:24 [PATCH] clk: sifive: allocate sufficient memory for struct __prci_data Vincent Chen
2020-06-25 22:13 ` Palmer Dabbelt
2020-06-29 23:23   ` Stephen Boyd
2020-06-29 23:34     ` Palmer Dabbelt
2020-06-29 23:37       ` Stephen Boyd

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).