Skip to content

Commit 2526612

Browse files
jasowangkuba-moo
authored andcommitted
virtio-net: fix race between set queues and probe
A race were found where set_channels could be called after registering but before virtnet_set_queues() in virtnet_probe(). Fixing this by moving the virtnet_set_queues() before netdevice registering. While at it, use _virtnet_set_queues() to avoid holding rtnl as the device is not even registered at that time. Cc: [email protected] Fixes: a220871 ("virtio-net: correctly enable multiqueue") Signed-off-by: Jason Wang <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Xuan Zhuo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6c58c88 commit 2526612

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/virtio_net.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4219,6 +4219,8 @@ static int virtnet_probe(struct virtio_device *vdev)
42194219
if (vi->has_rss || vi->has_rss_hash_report)
42204220
virtnet_init_default_rss(vi);
42214221

4222+
_virtnet_set_queues(vi, vi->curr_queue_pairs);
4223+
42224224
/* serialize netdev register + virtio_device_ready() with ndo_open() */
42234225
rtnl_lock();
42244226

@@ -4257,8 +4259,6 @@ static int virtnet_probe(struct virtio_device *vdev)
42574259
goto free_unregister_netdev;
42584260
}
42594261

4260-
virtnet_set_queues(vi, vi->curr_queue_pairs);
4261-
42624262
/* Assume link up if device can't report link status,
42634263
otherwise get link status from config. */
42644264
netif_carrier_off(dev);

0 commit comments

Comments
 (0)