Skip to content

Commit b5e33a1

Browse files
HoratiuVulturdavem330
authored andcommitted
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>
1 parent 42edc1f commit b5e33a1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/net/ethernet/mscc/ocelot_net.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ int ocelot_port_devlink_init(struct ocelot *ocelot, int port,
164164
struct devlink *dl = ocelot->devlink;
165165
struct devlink_port_attrs attrs = {};
166166

167+
memset(dlp, 0, sizeof(*dlp));
167168
memcpy(attrs.switch_id.id, &ocelot->base_mac, id_len);
168169
attrs.switch_id.id_len = id_len;
169170
attrs.phys.port_number = port;

0 commit comments

Comments
 (0)