Commit 037ca765 authored by YueHaibing's avatar YueHaibing Committed by Greg Kroah-Hartman

virtio_ring: Fix potential mem leak in virtqueue_add_indirect_packed

commit df0bfe75 upstream.

'desc' should be freed before leaving from err handing path.

Fixes: 1ce9e605 ("virtio_ring: introduce packed ring support")
Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
stable@vger.kernel.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 665c4bdd
...@@ -1004,6 +1004,7 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq, ...@@ -1004,6 +1004,7 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq,
if (unlikely(vq->vq.num_free < 1)) { if (unlikely(vq->vq.num_free < 1)) {
pr_debug("Can't add buf len 1 - avail = 0\n"); pr_debug("Can't add buf len 1 - avail = 0\n");
kfree(desc);
END_USE(vq); END_USE(vq);
return -ENOSPC; return -ENOSPC;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment