[net-next,v3,10/15] net: devlink: disallow port_attrs_set() to be called before register
diff mbox series

Message ID 20190324101438.6376-11-jiri@resnulli.us
State Accepted
Delegated to: David Miller
Headers show
  • devlink: small spring cleanup
Related show

Commit Message

Jiri Pirko March 24, 2019, 10:14 a.m. UTC
From: Jiri Pirko <jiri@mellanox.com>

Since the port attributes are static and cannot change during the port
lifetime, WARN_ON if some driver calls it after registration. Also, no
need to call notifications as it is noop anyway due to check of
devlink_port->registered there.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
 net/core/devlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff mbox series

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 35ae9980ce86..f4dbd404688f 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -5430,12 +5430,13 @@  void devlink_port_attrs_set(struct devlink_port *devlink_port,
 	struct devlink_port_attrs *attrs = &devlink_port->attrs;
+	if (WARN_ON(devlink_port->registered))
+		return;
 	attrs->set = true;
 	attrs->flavour = flavour;
 	attrs->port_number = port_number;
 	attrs->split = split;
 	attrs->split_subport_number = split_subport_number;
-	devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW);