Skip to contentSkip to conversation

at91: sama5d3: fix off-by-one array boundary checking for pdata_i2c

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

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 at91: sama5d3: fix off-by-one array boundary checking for pdata_i2c

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

---
 arch/arm/mach-at91/sama5d3_devices.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-at91/sama5d3_devices.c +1 -1
index 031168b..e456bd0 100644
@@ -322,7 +322,7 @@ void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_de
 {
 	struct i2c_gpio_platform_data *pdata;
 
-	if (i2c_id > ARRAY_SIZE(pdata_i2c))
+	if (i2c_id >= ARRAY_SIZE(pdata_i2c))
 		return;
 
 	i2c_register_board_info(i2c_id, devices, nr_devices);
Signature · 9 lines
1.8.1.2




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