virtio: fix memory leak in virtqueue_add()
authorWei Yongjun <weiyj.lk@gmail.com>
Tue, 2 Aug 2016 14:16:31 +0000 (14:16 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Sep 2016 06:32:36 +0000 (08:32 +0200)
commitfa54eea35b3882b18da94d932b78c519c3972bd8
treefa3527d49004d8195c1e58cbf73ccaa8706c16cc
parent9dddd02de0366eee747488e8b6829e265b3bf385
virtio: fix memory leak in virtqueue_add()

commit 58625edf9e2515ed41dac2a24fa8004030a87b87 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: Wei Yongjun <weiyj.lk@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/virtio/virtio_ring.c