Commit 67c128b4 authored by Wei Yongjun's avatar Wei Yongjun Committed by Kamal Mostafa

virtio: fix memory leak in virtqueue_add()

BugLink: http://bugs.launchpad.net/bugs/1621113

commit 58625edf upstream.

When using the indirect buffers feature, 'desc' is allocated in
virtqueue_add() but isn't freed before leaving on a ring full error,
causing a memory leak.

For example, it seems rather clear that this can trigger
with virtio net if mergeable buffers are not used.
Signed-off-by: default avatarWei Yongjun <weiyj.lk@gmail.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 85628375
...@@ -202,6 +202,8 @@ static inline int virtqueue_add(struct virtqueue *_vq, ...@@ -202,6 +202,8 @@ static inline int virtqueue_add(struct virtqueue *_vq,
* host should service the ring ASAP. */ * host should service the ring ASAP. */
if (out_sgs) if (out_sgs)
vq->notify(&vq->vq); vq->notify(&vq->vq);
if (indirect)
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