diff mbox series

[net-next] net: sparx5: mdb add/del handle non-sparx5 devices

Message ID 20220628075546.3560083-1-casper.casan@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: sparx5: mdb add/del handle non-sparx5 devices | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: linux-arm-kernel@lists.infradead.org vladimir.oltean@nxp.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Casper Andersson June 28, 2022, 7:55 a.m. UTC
When adding/deleting mdb entries on other net_devices, eg., tap
interfaces, it should not crash.

Signed-off-by: Casper Andersson <casper.casan@gmail.com>
---
 drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Steen Hegelund June 28, 2022, 12:55 p.m. UTC | #1
Hi Casper,

On Tue, 2022-06-28 at 09:55 +0200, Casper Andersson wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> When adding/deleting mdb entries on other net_devices, eg., tap
> interfaces, it should not crash.
> 
> Signed-off-by: Casper Andersson <casper.casan@gmail.com>
> ---
>  drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> index 40ef9fad3a77..ec07f7d0528c 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> @@ -397,6 +397,9 @@ static int sparx5_handle_port_mdb_add(struct net_device *dev,
>         bool is_host;
>         int res, err;
> 
> +       if (!sparx5_netdevice_check(dev))
> +               return -EOPNOTSUPP;
> +
>         is_host = netif_is_bridge_master(v->obj.orig_dev);
> 
>         /* When VLAN unaware the vlan value is not parsed and we receive vid 0.
> @@ -480,6 +483,9 @@ static int sparx5_handle_port_mdb_del(struct net_device *dev,
>         u32 mact_entry, res, pgid_entry[3], misc_cfg;
>         bool host_ena;
> 
> +       if (!sparx5_netdevice_check(dev))
> +               return -EOPNOTSUPP;
> +
>         if (!br_vlan_enabled(spx5->hw_bridge_dev))
>                 vid = 1;
>         else
> --
> 2.30.2
> 

Indeed!

Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Jakub Kicinski June 30, 2022, 3:22 a.m. UTC | #2
On Tue, 28 Jun 2022 14:55:22 +0200 Steen Hegelund wrote:
> On Tue, 2022-06-28 at 09:55 +0200, Casper Andersson wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> > 
> > When adding/deleting mdb entries on other net_devices, eg., tap
> > interfaces, it should not crash.
> > 
> > Signed-off-by: Casper Andersson <casper.casan@gmail.com>
>
> Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>

We need a Fixes tag here, when did it start crashing?
Casper Andersson June 30, 2022, 12:16 p.m. UTC | #3
Sorry, yes. This is supposed to go to net, not net-next. I will resubmit
with a fixes tag.

Best Regards,
Casper

On 2022-06-29 20:22, Jakub Kicinski wrote:
> On Tue, 28 Jun 2022 14:55:22 +0200 Steen Hegelund wrote:
> > On Tue, 2022-06-28 at 09:55 +0200, Casper Andersson wrote:
> > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> > > 
> > > When adding/deleting mdb entries on other net_devices, eg., tap
> > > interfaces, it should not crash.
> > > 
> > > Signed-off-by: Casper Andersson <casper.casan@gmail.com>
> >
> > Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> 
> We need a Fixes tag here, when did it start crashing?
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
index 40ef9fad3a77..ec07f7d0528c 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
@@ -397,6 +397,9 @@  static int sparx5_handle_port_mdb_add(struct net_device *dev,
 	bool is_host;
 	int res, err;
 
+	if (!sparx5_netdevice_check(dev))
+		return -EOPNOTSUPP;
+
 	is_host = netif_is_bridge_master(v->obj.orig_dev);
 
 	/* When VLAN unaware the vlan value is not parsed and we receive vid 0.
@@ -480,6 +483,9 @@  static int sparx5_handle_port_mdb_del(struct net_device *dev,
 	u32 mact_entry, res, pgid_entry[3], misc_cfg;
 	bool host_ena;
 
+	if (!sparx5_netdevice_check(dev))
+		return -EOPNOTSUPP;
+
 	if (!br_vlan_enabled(spx5->hw_bridge_dev))
 		vid = 1;
 	else