summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2019-03-24 11:14:36 +0100
committerDavid S. Miller <davem@davemloft.net>2019-03-24 14:55:31 -0400
commit2b239e7090b89d1e2b73b48300686221ca948637 (patch)
tree978ff229e987af5ed3615ea6da026ca3e33179a4 /net
parentd0d54e8c359399a8d07656779d5b6ddae68ef3c7 (diff)
downloadlinux-2b239e7090b89d1e2b73b48300686221ca948637.tar.bz2
net: devlink: warn on setting type on unregistered port
Port needs to be registered first before the type is set. Warn and bail-out in case it is not. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/devlink.c2
1 files changed, 2 insertions, 0 deletions
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);