Skip to content

Commit 9c5de24

Browse files
cappe987kuba-moo
authored andcommitted
net: sparx5: mdb add/del handle non-sparx5 devices
When adding/deleting mdb entries on other net_devices, eg., tap interfaces, it should not crash. Fixes: 3bacfcc ("net: sparx5: Add mdb handlers") Signed-off-by: Casper Andersson <[email protected]> Reviewed-by: Steen Hegelund <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0a18d80 commit 9c5de24

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ static int sparx5_handle_port_mdb_add(struct net_device *dev,
396396
u32 mact_entry;
397397
int res, err;
398398

399+
if (!sparx5_netdevice_check(dev))
400+
return -EOPNOTSUPP;
401+
399402
if (netif_is_bridge_master(v->obj.orig_dev)) {
400403
sparx5_mact_learn(spx5, PGID_CPU, v->addr, v->vid);
401404
return 0;
@@ -466,6 +469,9 @@ static int sparx5_handle_port_mdb_del(struct net_device *dev,
466469
u32 mact_entry, res, pgid_entry[3];
467470
int err;
468471

472+
if (!sparx5_netdevice_check(dev))
473+
return -EOPNOTSUPP;
474+
469475
if (netif_is_bridge_master(v->obj.orig_dev)) {
470476
sparx5_mact_forget(spx5, v->addr, v->vid);
471477
return 0;

0 commit comments

Comments
 (0)