diff options
author | Jason Wang <jasowang@redhat.com> | 2013-12-30 11:34:40 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-15 15:28:50 -0800 |
commit | 6a0827c4051600d836b16ed9cb6caf78b26573bc (patch) | |
tree | eb8ca8e5bf4b0c3c32d1429cd4c29295719bb015 | |
parent | fcd8e312578603626f0d78084d7ec2e444489aa4 (diff) | |
download | linux-3.10-6a0827c4051600d836b16ed9cb6caf78b26573bc.tar.gz linux-3.10-6a0827c4051600d836b16ed9cb6caf78b26573bc.tar.bz2 linux-3.10-6a0827c4051600d836b16ed9cb6caf78b26573bc.zip |
virtio-net: fix refill races during restore
[ Upstream commit 6cd4ce0099da7702f885b6fa9ebb49e3831d90b4 ]
During restoring, try_fill_recv() was called with neither napi lock nor napi
disabled. This can lead two try_fill_recv() was called in the same time. Fix
this by refilling before trying to enable napi.
Fixes 0741bcb5584f9e2390ae6261573c4de8314999f2
(virtio: net: Add freeze, restore handlers to support S4).
Cc: Amit Shah <amit.shah@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/net/virtio_net.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 68692af1f48..a0c05e07fee 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1745,16 +1745,17 @@ static int virtnet_restore(struct virtio_device *vdev) if (err) return err; - if (netif_running(vi->dev)) + if (netif_running(vi->dev)) { + for (i = 0; i < vi->curr_queue_pairs; i++) + if (!try_fill_recv(&vi->rq[i], GFP_KERNEL)) + schedule_delayed_work(&vi->refill, 0); + for (i = 0; i < vi->max_queue_pairs; i++) virtnet_napi_enable(&vi->rq[i]); + } netif_device_attach(vi->dev); - for (i = 0; i < vi->curr_queue_pairs; i++) - if (!try_fill_recv(&vi->rq[i], GFP_KERNEL)) - schedule_delayed_work(&vi->refill, 0); - mutex_lock(&vi->config_lock); vi->config_enable = true; mutex_unlock(&vi->config_lock); |