diff --git a/net/core/devlink.c b/net/core/devlink.c index d78c8cea7c3d..860ab3a721e0 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5328,6 +5328,8 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port, enum devlink_port_type type, void *type_dev) { + if (WARN_ON(!devlink_port->registered)) + return; devlink_port->type = type; devlink_port->type_dev = type_dev; devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW);