Skip to content

Commit d1a9b84

Browse files
IoanaCiorneikuba-moo
authored andcommitted
dpaa2-switch: check if the port priv is valid
Before accessing the port private structure make sure that there is still a non-NULL pointer there. A NULL pointer access can happen when we are on the remove path, some switch ports are unregistered and some are in the process of unregistering. Signed-off-by: Ioana Ciornei <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4e30e98 commit d1a9b84

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ static int dpaa2_switch_dellink(struct ethsw_core *ethsw, u16 vid)
394394

395395
for (i = 0; i < ethsw->sw_attr.num_ifs; i++) {
396396
ppriv_local = ethsw->ports[i];
397-
ppriv_local->vlans[vid] = 0;
397+
if (ppriv_local)
398+
ppriv_local->vlans[vid] = 0;
398399
}
399400

400401
return 0;
@@ -1896,9 +1897,11 @@ static int dpaa2_switch_port_del_vlan(struct ethsw_port_priv *port_priv, u16 vid
18961897
/* Delete VLAN from switch if it is no longer configured on
18971898
* any port
18981899
*/
1899-
for (i = 0; i < ethsw->sw_attr.num_ifs; i++)
1900-
if (ethsw->ports[i]->vlans[vid] & ETHSW_VLAN_MEMBER)
1900+
for (i = 0; i < ethsw->sw_attr.num_ifs; i++) {
1901+
if (ethsw->ports[i] &&
1902+
ethsw->ports[i]->vlans[vid] & ETHSW_VLAN_MEMBER)
19011903
return 0; /* Found a port member in VID */
1904+
}
19021905

19031906
ethsw->vlans[vid] &= ~ETHSW_VLAN_GLOBAL;
19041907

0 commit comments

Comments
 (0)