[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <174265451966.356712.5458994002489802674.stgit@pro.pro>
Date: Sat, 22 Mar 2025 17:41:59 +0300
From: Kirill Tkhai <tkhai@...ru>
To: netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: tkhai@...ru
Subject: [PATCH NET-PREV 33/51] net: Now check nobody calls register_netdevice() with nd_lock attached
At this moment after .newlink and .changelink are switched
to __register_netdevice(), there must not be calls of
register_netdevice() with lock attached.
Signed-off-by: Kirill Tkhai <tkhai@...ru>
---
net/core/dev.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 63ece39c9286..e6809a80644e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10847,25 +10847,14 @@ int register_netdevice(struct net_device *dev)
struct nd_lock *nd_lock;
int err;
- /* XXX: This "if" is to start one by one convertation
- * to use __register_netdevice() in devices, that
- * want to attach nd_lock themself (e.g., having newlink).
- * After all of them are converted, we remove this.
- */
- if (rcu_access_pointer(dev->nd_lock))
- return __register_netdevice(dev);
+ if (WARN_ON(rcu_access_pointer(dev->nd_lock)))
+ return -EINVAL;
nd_lock = alloc_nd_lock();
if (!nd_lock)
return -ENOMEM;
- /* This may be called from netdevice notifier, which is not converted
- * yet. The context is unknown: either some nd_lock is locked or not.
- * Sometimes here is nested mutex and sometimes is not. We use trylock
- * to silence lockdep assert about that.
- * It will be replaced by mutex_lock(), see next patches.
- */
- BUG_ON(!mutex_trylock(&nd_lock->mutex));
+ mutex_lock(&nd_lock->mutex);
attach_nd_lock(dev, nd_lock);
err = __register_netdevice(dev);
if (err)
Powered by blists - more mailing lists