From: "Michael S. Tsirkin" <mst@redhat.com>
To: Wei Yongjun <weiyj.lk@gmail.com>
Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH -next] virtio: fix possible memory leak in virtqueue_add()
Date: Tue, 2 Aug 2016 17:04:16 +0300 [thread overview]
Message-ID: <20160802170351-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1470146345-19531-1-git-send-email-weiyj.lk@gmail.com>
On Tue, Aug 02, 2016 at 01:59:05PM +0000, Wei Yongjun wrote:
> 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);
I think only if indirect is true, otherwise you will free
vq->vring.desc.
> return -ENOSPC;
> }
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Wei Yongjun <weiyj.lk@gmail.com>
Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next] virtio: fix possible memory leak in virtqueue_add()
Date: Tue, 2 Aug 2016 17:04:16 +0300 [thread overview]
Message-ID: <20160802170351-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1470146345-19531-1-git-send-email-weiyj.lk@gmail.com>
On Tue, Aug 02, 2016 at 01:59:05PM +0000, Wei Yongjun wrote:
> 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);
I think only if indirect is true, otherwise you will free
vq->vring.desc.
> return -ENOSPC;
> }
next prev parent reply other threads:[~2016-08-02 14:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-02 13:59 [PATCH -next] virtio: fix possible memory leak in virtqueue_add() Wei Yongjun
2016-08-02 13:59 ` Wei Yongjun
2016-08-02 14:04 ` Michael S. Tsirkin [this message]
2016-08-02 14:04 ` Michael S. Tsirkin
2016-08-02 14:16 ` [PATCH -next v2] " Wei Yongjun
2016-08-02 14:16 ` Wei Yongjun
2016-08-03 4:22 ` Michael S. Tsirkin
2016-08-03 4:22 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160802170351-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=weiyj.lk@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.