net: iosm: Prevent underflow in ipc_chnl_cfg_get()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 16 Aug 2021 11:13:33 +0000 (14:13 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Aug 2021 12:40:18 +0000 (13:40 +0100)
commit4f3f2e3fa0431b93745b110da1c365806c5acce3
treef84c05994cc19d332c972a1779841cc4036742ff
parent517c54d282392a2c7dedc80783886d2cd1836c0d
net: iosm: Prevent underflow in ipc_chnl_cfg_get()

The bounds check on "index" doesn't catch negative values.  Using
ARRAY_SIZE() directly is more readable and more robust because it prevents
negative values for "index".  Fortunately we only pass valid values to
ipc_chnl_cfg_get() so this patch does not affect runtime.

Reported-by: Solomon Ucko <solly.ucko@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: M Chetan Kumar <m.chetan.kumar@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wwan/iosm/iosm_ipc_chnl_cfg.c