Skip to contentSkip to conversation

clk: at91: fix count of periph clocks passed to pmc_data_allocate

PATCH In review Clément Léger 2 participants 3 messages Jun 9, 2021 – Jul 8, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: at91: fix count of periph clocks passed to pmc_data_allocate

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.

---
 drivers/clk/at91/sama5d2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/at91/sama5d2.c +1 -1
index 3d1f78176c3e..663b73a032ee 100644
@@ -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;
Signature · 1 line
2.32.0
#1 lore raw

hi,

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

Quoted 5 lines · Clément Léger

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.

Fixes a2038077de9a ("clk: at91: add sama5d2 PMC driver")
Quoted 20 lines
---
 drivers/clk/at91/sama5d2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/at91/sama5d2.c +1 -1
index 3d1f78176c3e..663b73a032ee 100644
@@ -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;
Signature · 1 line
2.32.0
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

Hi,

Quoted 6 lines · Alexandre Belloni

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.

Quoted 15 lines · Clément Léger
Quoted 6 lines

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.

Fixes a2038077de9a ("clk: at91: add sama5d2 PMC driver")
Quoted 4 lines
---
 drivers/clk/at91/sama5d2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines
Quoted 16 lines
drivers/clk/at91/sama5d2.c +1 -1
index 3d1f78176c3e..663b73a032ee 100644
@@ -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;
Signature · 1 line
2.32.0

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel