[PATCH AUTOSEL 4.4 11/12] virtio-blk: Fix memory leak among suspend/resume procedure

From: Sasha Levin
Date: Sat Jul 10 2021 - 19:57:23 EST


From: Xie Yongji <xieyongji@xxxxxxxxxxxxx>

[ Upstream commit b71ba22e7c6c6b279c66f53ee7818709774efa1f ]

The vblk->vqs should be freed before we call init_vqs()
in virtblk_restore().

Signed-off-by: Xie Yongji <xieyongji@xxxxxxxxxxxxx>
Link: https://lore.kernel.org/r/20210517084332.280-1-xieyongji@xxxxxxxxxxxxx
Acked-by: Jason Wang <jasowang@xxxxxxxxxx>
Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/block/virtio_blk.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index bdc3efacd0d2..2bcc2bc64149 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -808,6 +808,8 @@ static int virtblk_freeze(struct virtio_device *vdev)
blk_mq_stop_hw_queues(vblk->disk->queue);

vdev->config->del_vqs(vdev);
+ kfree(vblk->vqs);
+
return 0;
}

--
2.30.2