virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] virtio: fix possible memory leak in virtqueue_add()
@ 2016-08-02 13:59 Wei Yongjun
  2016-08-02 14:04 ` Michael S. Tsirkin
  2016-08-02 14:16 ` [PATCH -next v2] " Wei Yongjun
  0 siblings, 2 replies; 4+ messages in thread
From: Wei Yongjun @ 2016-08-02 13:59 UTC (permalink / raw)
  To: Michael S . Tsirkin; +Cc: Wei Yongjun, linux-kernel, virtualization

desc may 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@gmail.com>
---
 drivers/virtio/virtio_ring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 114a0c8..bda71ef 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -328,6 +328,7 @@ static inline int virtqueue_add(struct virtqueue *_vq,
 		if (out_sgs)
 			vq->notify(&vq->vq);
 		END_USE(vq);
+		kfree(desc);
 		return -ENOSPC;
 	}

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-03  4:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02 13:59 [PATCH -next] virtio: fix possible memory leak in virtqueue_add() Wei Yongjun
2016-08-02 14:04 ` Michael S. Tsirkin
2016-08-02 14:16 ` [PATCH -next v2] " Wei Yongjun
2016-08-03  4:22   ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).