Skip to content

Commit

Permalink
net: loopback: Hold rtnl_net_lock() in blackhole_netdev_init().
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kuniyuki Iwashima authored and Jakub Kicinski committed Jan 15, 2025
1 parent 7a649f3 commit 2248c05
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,12 @@ static int __init blackhole_netdev_init(void)
if (!blackhole_netdev)
return -ENOMEM;

rtnl_lock();
rtnl_net_lock(&init_net);
dev_init_scheduler(blackhole_netdev);
dev_activate(blackhole_netdev);
rtnl_unlock();
rtnl_net_unlock(&init_net);

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

return 0;
}
Expand Down

0 comments on commit 2248c05

Please sign in to comment.