virtio_net: Fix error handling in virtnet_restore()
authorXie Yongji <xieyongji@bytedance.com>
Mon, 17 May 2021 08:45:16 +0000 (16:45 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:17:53 +0000 (16:17 +0200)
[ Upstream commit 3f2869cace829fb4b80fc53b3ddaa7f4ba9acbf1 ]

Do some cleanups in virtnet_restore() when virtnet_cpu_notif_add() failed.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Link: https://lore.kernel.org/r/20210517084516.332-1-xieyongji@bytedance.com
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/virtio_net.c

index 71052d17c9ae57c00c62bc6bd3fbeceb168e3407..c8abbf81ef5243b5468e9e24c7b8945f1886818c 100644 (file)
@@ -2765,8 +2765,11 @@ static __maybe_unused int virtnet_restore(struct virtio_device *vdev)
        virtnet_set_queues(vi, vi->curr_queue_pairs);
 
        err = virtnet_cpu_notif_add(vi);
-       if (err)
+       if (err) {
+               virtnet_freeze_down(vdev);
+               remove_vq_common(vi);
                return err;
+       }
 
        return 0;
 }