Skip to content

Commit 2248c05

Browse files
q2venkuba-moo
authored andcommitted
net: loopback: Hold rtnl_net_lock() in blackhole_netdev_init().
blackhole_netdev is the global device in init_net. Let's hold rtnl_net_lock(&init_net) in blackhole_netdev_init(). While at it, the unnecessary dev_net_set() call is removed, which is done in alloc_netdev_mqs(). Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20250114081352.47404-1-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 7a649f3 commit 2248c05

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/net/loopback.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,12 @@ static int __init blackhole_netdev_init(void)
264264
if (!blackhole_netdev)
265265
return -ENOMEM;
266266

267-
rtnl_lock();
267+
rtnl_net_lock(&init_net);
268268
dev_init_scheduler(blackhole_netdev);
269269
dev_activate(blackhole_netdev);
270-
rtnl_unlock();
270+
rtnl_net_unlock(&init_net);
271271

272272
blackhole_netdev->flags |= IFF_UP | IFF_RUNNING;
273-
dev_net_set(blackhole_netdev, &init_net);
274273

275274
return 0;
276275
}

0 commit comments

Comments
 (0)