Commit 58625edf authored by Wei Yongjun's avatar Wei Yongjun Committed by Michael S. Tsirkin

virtio: fix memory leak in virtqueue_add()

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 <>
Signed-off-by: Michael S. Tsirkin's avatarMichael S. Tsirkin <>
parent 29b4817d
......@@ -327,6 +327,8 @@ static inline int virtqueue_add(struct virtqueue *_vq,
* host should service the ring ASAP. */
if (out_sgs)
if (indirect)
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