]> git.baikalelectronics.ru Git - kernel.git/commit
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)
committerDavid S. Miller <davem@davemloft.net>
Thu, 14 Feb 2019 06:11:53 +0000 (22:11 -0800)
commit64407601deb07612f912177f97e7f62c5d5cc376
treecf8adf4a6803706b5ed36d7e6b7f72740c33b6e0
parenta78abd9cfb6cd7ca03693614315cd9210d7f40fd
net: dsa: bcm_sf2: potential array overflow in bcm_sf2_sw_suspend()

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: 33f10dfb87fb ("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>
drivers/net/dsa/bcm_sf2.c