virtio_ring: Fix potential mem leak in virtqueue_add_indirect_packed
authorYueHaibing <yuehaibing@huawei.com>
Tue, 12 Mar 2019 07:06:53 +0000 (15:06 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 12 May 2019 17:11:35 +0000 (13:11 -0400)
'desc' should be freed before leaving from err handing path.

Fixes: 1ce9e6055fa0 ("virtio_ring: introduce packed ring support")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
stable@vger.kernel.org

drivers/virtio/virtio_ring.c

index 5df92c3..0210104 100644 (file)
@@ -1004,6 +1004,7 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq,
 
        if (unlikely(vq->vq.num_free < 1)) {
                pr_debug("Can't add buf len 1 - avail = 0\n");
+               kfree(desc);
                END_USE(vq);
                return -ENOSPC;
        }