linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: at91: fix count of periph clocks passed to pmc_data_allocate
@ 2021-06-09  8:01 Clément Léger
  2021-06-09  8:31 ` Alexandre Belloni
  0 siblings, 1 reply; 3+ messages in thread
From: Clément Léger @ 2021-06-09  8:01 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Nicolas Ferre,
	Alexandre Belloni, Ludovic Desroches
  Cc: linux-clk, linux-arm-kernel, linux-kernel

When allocating clk_hw structure, only the periph32 clocks are considered.
Since sama5d2_periphck are also added to the phws there is currently an
out of bound write. Fix this by adding the count of periphck to periph32ck.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 drivers/clk/at91/sama5d2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c
index 3d1f78176c3e..663b73a032ee 100644
--- a/drivers/clk/at91/sama5d2.c
+++ b/drivers/clk/at91/sama5d2.c
@@ -170,7 +170,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
 
 	sama5d2_pmc = pmc_data_allocate(PMC_AUDIOPLLCK + 1,
 					nck(sama5d2_systemck),
-					nck(sama5d2_periph32ck),
+					nck(sama5d2_periphck) + nck(sama5d2_periph32ck),
 					nck(sama5d2_gck), 3);
 	if (!sama5d2_pmc)
 		return;
-- 
2.32.0


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

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

* Re: [PATCH] clk: at91: fix count of periph clocks passed to pmc_data_allocate
  2021-06-09  8:01 [PATCH] clk: at91: fix count of periph clocks passed to pmc_data_allocate Clément Léger
@ 2021-06-09  8:31 ` Alexandre Belloni
  2021-07-08 14:13   ` Clément Léger
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2021-06-09  8:31 UTC (permalink / raw)
  To: Clément Léger
  Cc: Stephen Boyd, Michael Turquette, linux-kernel, Ludovic Desroches,
	linux-clk, linux-arm-kernel

hi,

Subject should have been:
clk: at91: sama5d2: fix count of periph clocks passed to pmc_data_allocate



On 09/06/2021 10:01:44+0200, Clément Léger wrote:
> When allocating clk_hw structure, only the periph32 clocks are considered.
> Since sama5d2_periphck are also added to the phws there is currently an
> out of bound write. Fix this by adding the count of periphck to periph32ck.
> 
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
Fixes: a2038077de9a ("clk: at91: add sama5d2 PMC driver")

> ---
>  drivers/clk/at91/sama5d2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c
> index 3d1f78176c3e..663b73a032ee 100644
> --- a/drivers/clk/at91/sama5d2.c
> +++ b/drivers/clk/at91/sama5d2.c
> @@ -170,7 +170,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
>  
>  	sama5d2_pmc = pmc_data_allocate(PMC_AUDIOPLLCK + 1,
>  					nck(sama5d2_systemck),
> -					nck(sama5d2_periph32ck),
> +					nck(sama5d2_periphck) + nck(sama5d2_periph32ck),
>  					nck(sama5d2_gck), 3);
>  	if (!sama5d2_pmc)
>  		return;
> -- 
> 2.32.0
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

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

* Re: [PATCH] clk: at91: fix count of periph clocks passed to pmc_data_allocate
  2021-06-09  8:31 ` Alexandre Belloni
@ 2021-07-08 14:13   ` Clément Léger
  0 siblings, 0 replies; 3+ messages in thread
From: Clément Léger @ 2021-07-08 14:13 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Stephen Boyd, Michael Turquette, linux-kernel, Ludovic Desroches,
	linux-clk, linux-arm-kernel

Hi,

Le Wed, 9 Jun 2021 10:31:01 +0200,
Alexandre Belloni <alexandre.belloni@bootlin.com> a écrit :

> hi,
> 
> Subject should have been:
> clk: at91: sama5d2: fix count of periph clocks passed to
> pmc_data_allocate
> 

This patch can actually be discarded since it won't fix allocation at
all but will just allocate more data than needed since nck already
returns the max .id field of the periph array.

> 
> 
> On 09/06/2021 10:01:44+0200, Clément Léger wrote:
> > When allocating clk_hw structure, only the periph32 clocks are
> > considered. Since sama5d2_periphck are also added to the phws there
> > is currently an out of bound write. Fix this by adding the count of
> > periphck to periph32ck.
> > 
> > Signed-off-by: Clément Léger <clement.leger@bootlin.com>  
> Fixes: a2038077de9a ("clk: at91: add sama5d2 PMC driver")
> 
> > ---
> >  drivers/clk/at91/sama5d2.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c
> > index 3d1f78176c3e..663b73a032ee 100644
> > --- a/drivers/clk/at91/sama5d2.c
> > +++ b/drivers/clk/at91/sama5d2.c
> > @@ -170,7 +170,7 @@ static void __init sama5d2_pmc_setup(struct
> > device_node *np) 
> >  	sama5d2_pmc = pmc_data_allocate(PMC_AUDIOPLLCK + 1,
> >  					nck(sama5d2_systemck),
> > -					nck(sama5d2_periph32ck),
> > +					nck(sama5d2_periphck) +
> > nck(sama5d2_periph32ck), nck(sama5d2_gck), 3);
> >  	if (!sama5d2_pmc)
> >  		return;
> > -- 
> > 2.32.0
> >   
> 


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

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

end of thread, other threads:[~2021-07-08 14:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09  8:01 [PATCH] clk: at91: fix count of periph clocks passed to pmc_data_allocate Clément Léger
2021-06-09  8:31 ` Alexandre Belloni
2021-07-08 14:13   ` Clément Léger

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