From: Dan Carpenter Date: Tue, 15 Sep 2015 06:54:33 +0000 (+0300) Subject: staging: wilc1000: off by one in get_handler_from_id() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6ae9ac0b61a752fc95298820debde88c10bdb53e;p=openwrt%2Fstaging%2Fblogic.git 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') Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 59a1a9d93d6a..621fd1867633 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -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]; }