[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221201164608.209537-8-jiri@resnulli.us>
Date: Thu, 1 Dec 2022 17:46:08 +0100
From: Jiri Pirko <jiri@...nulli.us>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
edumazet@...gle.com, yangyingliang@...wei.com, leon@...nel.org
Subject: [patch net-next RFC 7/7] devlink: assert if devl_port_register/unregister() is called on unregistered devlink instance
From: Jiri Pirko <jiri@...dia.com>
Now when all drivers do call devl_port_register/unregister() withing the
time frame during which the devlink is registered, put and assertion to
the functions to check that and avoid going back.
Signed-off-by: Jiri Pirko <jiri@...dia.com>
---
net/core/devlink.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index fca3ebee97b0..c46dd7753368 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -10088,6 +10088,7 @@ int devl_port_register(struct devlink *devlink,
struct devlink_port *devlink_port,
unsigned int port_index)
{
+ ASSERT_DEVLINK_REGISTERED(devlink);
devl_assert_locked(devlink);
if (devlink_port_index_exists(devlink, port_index))
@@ -10145,6 +10146,7 @@ EXPORT_SYMBOL_GPL(devlink_port_register);
*/
void devl_port_unregister(struct devlink_port *devlink_port)
{
+ ASSERT_DEVLINK_REGISTERED(devlink_port->devlink);
lockdep_assert_held(&devlink_port->devlink->lock);
WARN_ON(devlink_port->type != DEVLINK_PORT_TYPE_NOTSET);
--
2.37.3
Powered by blists - more mailing lists