net: dsa: bcm_sf2: potential array overflow in bcm_sf2_sw_suspend()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 13 Feb 2019 08:23:04 +0000 (11:23 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Mar 2019 19:09:46 +0000 (20:09 +0100)
commit388f3adb2729ca6ce74a9147fe5cc5c12f36018b
tree423caa54711c34ac04d7e8807690bb390273ef0c
parent8ab49fd5b0728778500fa9c88e2dc174651bdd14
net: dsa: bcm_sf2: potential array overflow in bcm_sf2_sw_suspend()

[ Upstream commit 8d6ea932856c7087ce8c3d0e79494b7d5386f962 ]

The value of ->num_ports comes from bcm_sf2_sw_probe() and it is less
than or equal to DSA_MAX_PORTS.  The ds->ports[] array is used inside
the dsa_is_user_port() and dsa_is_cpu_port() functions.  The ds->ports[]
array is allocated in dsa_switch_alloc() and it has ds->num_ports
elements so this leads to a static checker warning about a potential out
of bounds read.

Fixes: 8cfa94984c9c ("net: dsa: bcm_sf2: add suspend/resume callbacks")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/dsa/bcm_sf2.c