From: Wei Yongjun Date: Tue, 2 Aug 2016 14:16:31 +0000 (+0000) Subject: virtio: fix memory leak in virtqueue_add() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=58625edf9e2515ed41dac2a24fa8004030a87b87;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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. Cc: stable@vger.kernel.org Signed-off-by: Wei Yongjun Signed-off-by: Michael S. Tsirkin --- diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 114a0c88afb8..5ed228ddadba 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -327,6 +327,8 @@ static inline int virtqueue_add(struct virtqueue *_vq, * host should service the ring ASAP. */ if (out_sgs) vq->notify(&vq->vq); + if (indirect) + kfree(desc); END_USE(vq); return -ENOSPC; }