Skip to contentSkip to conversation

clk: stm32: fix clock array size for STM32MP21

PATCH Applied [email protected] 2 participants 2 messages Oct 12

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

PATCH 1/1 clk: stm32: fix clock array size for STM32MP21

From: Gabriel Fernandez <[email protected]>

STM32MP21_LAST_CLK is used as the number of entries of the onecell clk_hw array allocated in stm32_rcc_clock_init(), and as the bound of the clock IDs it can hold. It was wrongly set to CK_SCMI_KER_ETR (112), which belongs to the SCMI clock ID range, whereas the RCC clock IDs go up to CK_KER_STM (289).

As a result the array is too small, and registering a clock whose ID is greater than 111 writes past the end of the allocated clk_hw array (hws[cfg_clock->id] = hw), and consumers requesting such a clock get rejected or read out of bounds.

Define STM32MP21_LAST_CLK as CK_KER_STM + 1 so that the array covers all the RCC clock IDs.

No device tree node uses the STM32MP21 RCC driver yet, so there is no need to backport this patch to stable kernels.

Fixes 37ae8501cdb0 ("clk: stm32: introduce clocks for STM32MP21 platform")
---
 drivers/clk/stm32/clk-stm32mp21.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/stm32/clk-stm32mp21.c +2 -2
index bdb17419908c..961a228d8c64 100644
@@ -17,8 +17,8 @@
 #include <dt-bindings/clock/st,stm32mp21-rcc.h>
 #include <dt-bindings/reset/st,stm32mp21-rcc.h>
 
-/* Max clock binding value */
-#define STM32MP21_LAST_CLK	CK_SCMI_KER_ETR
+/* Number of RCC clock bindings (highest RCC clock ID + 1) */
+#define STM32MP21_LAST_CLK	(CK_KER_STM + 1)
 
 /* Clock security definition */
 #define SECF_NONE		-1

base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a

Signature · 1 line
2.43.0