virtio_ring: Fix potential mem leak in virtqueue_add_indirect_packed

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

Fixes: 1ce9e6055f ("virtio_ring: introduce packed ring support")
Signed-off-by: YueHaibing <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Acked-by: Jason Wang <[email protected]>
[email protected]
This commit is contained in:
YueHaibing 2019-03-12 15:06:53 +08:00 • committed by Michael S. Tsirkin
commit df0bfe7501

View 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;
}