staging: wilc1000: fix infinite loop and out-of-bounds access
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Mon, 30 Apr 2018 12:50:40 +0000 (07:50 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 May 2018 20:55:51 +0000 (13:55 -0700)
commitad109ba1378679f922f7286e7a9e50e2be778d87
tree4b36a640e28e5be94e3b2e44e55db4fad436958e
parentba36d10ed146c8f997d61a9eefc1a3319ef6a44f
staging: wilc1000: fix infinite loop and out-of-bounds access

If i < slot_id is initially true then it will remain true. Also,
as i is being decremented it will end up accessing memory out of
bounds.

Fix this by incrementing *i* instead of decrementing it.

Addresses-Coverity-ID: 1468454 ("Infinite loop")
Fixes: faa657641081 ("staging: wilc1000: refactor scan() to free kmalloc memory on failure cases")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Ajay Singh <ajay.kathat@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c