[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160905164349.749160072@linuxfoundation.org>
Date:   Mon,  5 Sep 2016 18:43:35 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     linux-kernel@...r.kernel.org
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        stable@...r.kernel.org, Wei Yongjun <weiyj.lk@...il.com>,
        "Michael S. Tsirkin" <mst@...hat.com>
Subject: [PATCH 4.4 012/113] virtio: fix memory leak in virtqueue_add()
4.4-stable review patch.  If anyone has any objections, please let me know.
------------------
From: Wei Yongjun <weiyj.lk@...il.com>
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@...il.com>
Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
 drivers/virtio/virtio_ring.c |    2 ++
 1 file changed, 2 insertions(+)
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -202,6 +202,8 @@ static inline int virtqueue_add(struct v
 		 * host should service the ring ASAP. */
 		if (out_sgs)
 			vq->notify(&vq->vq);
+		if (indirect)
+			kfree(desc);
 		END_USE(vq);
 		return -ENOSPC;
 	}
Powered by blists - more mailing lists
 
