Skip to contentSkip to conversation

tegra: fix off-by-one array boundary checking for uart_id_to_base

PATCH New Axel Lin 1 participant 1 message Jun 4, 2013

Subsystems (4)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 tegra: fix off-by-one array boundary checking for uart_id_to_base

id is used as array subscript, so it's valid value range is 0 ... ARRAY_SIZE -1.

---
 arch/arm/mach-tegra/include/mach/lowlevel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-tegra/include/mach/lowlevel.h +1 -1
index b7c01c0..361b12e 100644
@@ -136,7 +136,7 @@ static inline long tegra20_get_debuguart_base(void)
 		return 0;
 
 	id = (odmdata & T20_ODMDATA_UARTID_MASK) >> T20_ODMDATA_UARTID_SHIFT;
-	if (id > ARRAY_SIZE(uart_id_to_base))
+	if (id >= ARRAY_SIZE(uart_id_to_base))
 		return 0;
 
 	return uart_id_to_base[id];
Signature · 9 lines
1.8.1.2




_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox