[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1470147391-20549-1-git-send-email-weiyj.lk@gmail.com>
Date: Tue, 2 Aug 2016 14:16:31 +0000
From: Wei Yongjun <weiyj.lk@...il.com>
To: "Michael S . Tsirkin" <mst@...hat.com>
Cc: Wei Yongjun <weiyj.lk@...il.com>,
virtualization@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Subject: [PATCH -next v2] virtio: fix possible memory leak in virtqueue_add()
'desc' is malloced in virtqueue_add() and should be freed before
leaving from the error handling cases, otherwise it will cause
memory leak.
Signed-off-by: Wei Yongjun <weiyj.lk@...il.com>
---
drivers/virtio/virtio_ring.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 114a0c8..e4be912 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -328,6 +328,8 @@ static inline int virtqueue_add(struct virtqueue *_vq,
if (out_sgs)
vq->notify(&vq->vq);
END_USE(vq);
+ if (indirect)
+ kfree(desc);
return -ENOSPC;
}
Powered by blists - more mailing lists