summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrice Chotard <[email protected]>2026-02-10 15:57:35 +0100
committerPatrice Chotard <[email protected]>2026-02-24 14:12:34 +0100
commit5d5195073ca4913a7eb82e0354e45ba8504feb84 (patch)
tree3c718e8baf4641c74907fb56c3ba4553297c2d90
parent71433d2771611961c5ccdc4f335bc4d147c3b5d3 (diff)
stm32mp: fix array bounds checks
Fix index check against array size. If that index is equal to the array size, we'll access one-past-the-end of the array. Signed-off-by: Patrice Chotard <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]>
-rw-r--r--arch/arm/mach-stm32mp/stm32mp2/cpu.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/arm/mach-stm32mp/stm32mp2/cpu.c b/arch/arm/mach-stm32mp/stm32mp2/cpu.c
index e081dc605b8..a8a6bcf8ab4 100644
--- a/arch/arm/mach-stm32mp/stm32mp2/cpu.c
+++ b/arch/arm/mach-stm32mp/stm32mp2/cpu.c
@@ -148,7 +148,7 @@ static void setup_boot_mode(void)
__func__, boot_ctx, boot_mode, instance, forced_mode);
switch (boot_mode & TAMP_BOOT_DEVICE_MASK) {
case BOOT_SERIAL_UART:
- if (instance > ARRAY_SIZE(serial_addr))
+ if (instance >= ARRAY_SIZE(serial_addr))
break;
/* serial : search associated node in devicetree */
sprintf(cmd, "serial@%x", serial_addr[instance]);
@@ -178,7 +178,7 @@ static void setup_boot_mode(void)
break;
case BOOT_FLASH_SD:
case BOOT_FLASH_EMMC:
- if (instance > ARRAY_SIZE(sdmmc_addr))
+ if (instance >= ARRAY_SIZE(sdmmc_addr))
break;
/* search associated sdmmc node in devicetree */
sprintf(cmd, "mmc@%x", sdmmc_addr[instance]);