staging: gdm724x: fix a couple array overflows
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 8 Feb 2017 07:18:08 +0000 (10:18 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2017 12:10:20 +0000 (13:10 +0100)
commitcd47e4d69abfd5a3e85ba4ff282db5acfffd6fc2
treeb48d3313c50fc01c8d442bbba75416a8f8070074
parent57e60850e741137b37c302a4b569d33ad97631b0
staging: gdm724x: fix a couple array overflows

The find_dev_index() function is frustrating.  If you give it an invalid
index then it returns 0.  That was the intent except there is an
off-by-one so it can return MAX_NIC_TYPE which is one higher than we
want.

There is one caller which had a sanity check to catch invalid returns,
but the other two callers assumed that index was valid.

My feeling is that when we are given invalid indexes, that should be
treated like an error and we abandon what we were doing.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gdm724x/gdm_lte.c