diff options
author | Horatiu Vultur <horatiu.vultur@microchip.com> | 2021-08-19 19:49:57 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-08-20 16:36:42 +0300 |
commit | b5e33a1571580430ff4c7bd5b176d0450e9918db (patch) | |
tree | f62ed4b4d93048b7c605434196e509cba9e6dc9b /drivers/net/ethernet/mscc | |
parent | 42edc1fca4b5a000e8e2c1e38f4e08a6b9f7bcb7 (diff) | |
download | linux-b5e33a1571580430ff4c7bd5b176d0450e9918db.tar.xz |
net: mscc: ocelot: be able to reuse a devlink_port after teardown
There are cases where we would like to continue probing the switch even
if one port has failed to probe. When that happens, we need to
unregister a devlink_port of type DEVLINK_PORT_FLAVOUR_PHYSICAL and
re-register it of type DEVLINK_PORT_FLAVOUR_UNUSED.
This is fine, except when calling devlink_port_attrs_set on a structure
on which devlink_port_register has been previously called, there is a
WARN_ON in devlink_port_attrs_set that devlink_port->devlink must be
NULL.
So don't assume that the memory behind dlp is clean when calling
ocelot_port_devlink_init, just zero-initialize it.
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mscc')
-rw-r--r-- | drivers/net/ethernet/mscc/ocelot_net.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 5e8965be968a..9044737936d2 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -164,6 +164,7 @@ int ocelot_port_devlink_init(struct ocelot *ocelot, int port, struct devlink *dl = ocelot->devlink; struct devlink_port_attrs attrs = {}; + memset(dlp, 0, sizeof(*dlp)); memcpy(attrs.switch_id.id, &ocelot->base_mac, id_len); attrs.switch_id.id_len = id_len; attrs.phys.port_number = port; |