Skip to contentSkip to conversation

staging: wilc1000: off by one in get_handler_from_id()

PATCH New Dan Carpenter 1 participant 1 message Sep 15, 2015

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

PATCH 1/1 staging: wilc1000: off by one in get_handler_from_id()

The > should be >= here or we read beyond the end of the array.

Fixes d42ab0838d04 ('staging: wilc1000: use id value as argument')
drivers/staging/wilc1000/host_interface.c +1 -1
index 59a1a9d..621fd18 100644
@@ -637,7 +637,7 @@ static int get_id_from_handler(tstrWILC_WFIDrv *handler)
 
 static tstrWILC_WFIDrv *get_handler_from_id(int id)
 {
-	if (id <= 0 || id > ARRAY_SIZE(wfidrv_list))
+	if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
 		return NULL;
 	return wfidrv_list[id];
 }