Message ID | 20250114081352.47404-1-kuniyu@amazon.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v1,net-next] net: loopback: Hold rtnl_net_lock() in blackhole_netdev_init(). | expand |
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 1993b90b1a5f..c8840c3b9a1b 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -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; }
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> --- drivers/net/loopback.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)