# \[PATCH NET-PREV 26/51\] 6lowpan: Use \_\_register\_netdevice in .newlink

- From: Kirill Tkhai \<hidden\>
- Date: 2025-03-22 14:41:12 
- List: netdev
- Page: https://ratatoskr.run/netdev/2025/03/2982385
- Thread: https://ratatoskr.run/netdev/2025/03/2982413/t.md

```text
The objective is to conform .newlink with its callers,
which already assign nd_lock (and matches master nd_lock
if there is one).

Signed-off-by: Kirill Tkhai <redacted>
---
 net/6lowpan/core.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/6lowpan/core.c b/net/6lowpan/core.c
index 850d4a185f55..b5cbf85b291c 100644
--- a/net/6lowpan/core.c
+++ b/net/6lowpan/core.c
@@ -39,7 +39,7 @@ int lowpan_register_netdevice(struct net_device *dev,
 
 	dev->ndisc_ops = &lowpan_ndisc_ops;
 
-	ret = register_netdevice(dev);
+	ret = __register_netdevice(dev);
 	if (ret < 0)
 		return ret;
 
@@ -52,10 +52,18 @@ EXPORT_SYMBOL(lowpan_register_netdevice);
 int lowpan_register_netdev(struct net_device *dev,
 			   enum lowpan_lltypes lltype)
 {
+	struct nd_lock *nd_lock;
 	int ret;
 
 	rtnl_lock();
+	if (!attach_new_nd_lock(dev))
+		goto out;
+	lock_netdev(dev, &nd_lock);
 	ret = lowpan_register_netdevice(dev, lltype);
+	if (ret)
+		detach_nd_lock(dev);
+	unlock_netdev(nd_lock);
+out:
 	rtnl_unlock();
 	return ret;
 }

```
