]> git.baikalelectronics.ru Git - kernel.git/commit
net: dsa: bcm_sf2: Fix array overrun in bcm_sf2_num_active_ports()
authorFlorian Fainelli <f.fainelli@gmail.com>
Thu, 16 Sep 2021 21:33:35 +0000 (14:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 17 Sep 2021 13:21:46 +0000 (14:21 +0100)
commitf33392fd4520b9970701d0aa3d77358eff30e670
tree8dbd658f239e9c8bea35e0253613ec158e7a118c
parent7d582ac2f67dfc4be292c88c5e3adbc8771578ed
net: dsa: bcm_sf2: Fix array overrun in bcm_sf2_num_active_ports()

After 10224baad337 ("net: dsa: b53: Set correct number of ports in the
DSA struct") we stopped setting dsa_switch::num_ports to DSA_MAX_PORTS,
which created an off by one error between the statically allocated
bcm_sf2_priv::port_sts array (of size DSA_MAX_PORTS). When
dsa_is_cpu_port() is used, we end-up accessing an out of bounds member
and causing a NPD.

Fix this by iterating with the appropriate port count using
ds->num_ports.

Fixes: 10224baad337 ("net: dsa: b53: Set correct number of ports in the DSA struct")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/bcm_sf2.c