Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51b8131

Browse files
jasowangdavem330
authored andcommitted
virtio-net: set queues after driver_ok
Commit 2526612 ("virtio-net: fix race between set queues and probe") tries to fix the race between set queues and probe by calling _virtnet_set_queues() before DRIVER_OK is set. This violates virtio spec. Fixing this by setting queues after virtio_device_ready(). Note that rtnl needs to be held for userspace requests to change the number of queues. So we are serialized in this way. Fixes: 2526612 ("virtio-net: fix race between set queues and probe") Reported-by: Dragos Tatulea <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Jason Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9ebbb29 commit 51b8131

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,8 +4219,6 @@ 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-
42244222
/* serialize netdev register + virtio_device_ready() with ndo_open() */
42254223
rtnl_lock();
42264224

@@ -4233,6 +4231,8 @@ static int virtnet_probe(struct virtio_device *vdev)
42334231

42344232
virtio_device_ready(vdev);
42354233

4234+
_virtnet_set_queues(vi, vi->curr_queue_pairs);
4235+
42364236
/* a random MAC address has been assigned, notify the device.
42374237
* We don't fail probe if VIRTIO_NET_F_CTRL_MAC_ADDR is not there
42384238
* because many devices work fine without getting MAC explicitly

0 commit comments

Comments
 (0)