mlxsw: spectrum_span: Do not dereference destination netdev
authorIdo Schimmel <idosch@mellanox.com>
Tue, 14 Jul 2020 14:20:58 +0000 (17:20 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Jul 2020 21:50:49 +0000 (14:50 -0700)
Currently, the destination netdev to which we mirror must be a valid
netdev. However, this is going to change with the introduction of
mirroring towards the CPU port, as the CPU port does not have a backing
netdev.

Avoid dereferencing the destination netdev when it is not clear if it is
valid or not.

Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c

index 40289af..0ef9505 100644 (file)
@@ -692,16 +692,15 @@ mlxsw_sp_span_entry_configure(struct mlxsw_sp *mlxsw_sp,
                goto set_parms;
 
        if (sparms.dest_port->mlxsw_sp != mlxsw_sp) {
-               netdev_err(span_entry->to_dev, "Cannot mirror to %s, which belongs to a different mlxsw instance",
-                          sparms.dest_port->dev->name);
+               dev_err(mlxsw_sp->bus_info->dev,
+                       "Cannot mirror to a port which belongs to a different mlxsw instance\n");
                sparms.dest_port = NULL;
                goto set_parms;
        }
 
        err = span_entry->ops->configure(span_entry, sparms);
        if (err) {
-               netdev_err(span_entry->to_dev, "Failed to offload mirror to %s",
-                          sparms.dest_port->dev->name);
+               dev_err(mlxsw_sp->bus_info->dev, "Failed to offload mirror\n");
                sparms.dest_port = NULL;
                goto set_parms;
        }