All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tiwei Bie <tiwei.bie@intel.com>
To: Ilya Maximets <i.maximets@samsung.com>
Cc: dev@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>,
	Zhihong Wang <zhihong.wang@intel.com>,
	Junjie Chen <junjie.j.chen@intel.com>,
	stable@dpdk.org
Subject: Re: [PATCH] vhost: fix zmbufs array leak after NUMA realloc
Date: Thu, 16 Aug 2018 13:31:08 +0800	[thread overview]
Message-ID: <20180816053108.GA8252@debian> (raw)
In-Reply-To: <20180815145439.2513-1-i.maximets@samsung.com>

On Wed, Aug 15, 2018 at 05:54:39PM +0300, Ilya Maximets wrote:
> 'numa_realloc()' allocates 'zmbufs' even if zero copy mode
> is not configured. This leads to memory leak, because array
> is freed only for zero copy case.
> 
> Fixes: 2651726defb7 ("vhost: do deep copy while reallocating queue")
> CC: stable@dpdk.org
> 
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---
>  lib/librte_vhost/vhost_user.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index a2d4c9ffc..9aa1ce118 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -357,11 +357,13 @@ numa_realloc(struct virtio_net *dev, int index)
>  		memcpy(vq, old_vq, sizeof(*vq));
>  		TAILQ_INIT(&vq->zmbuf_list);
>  
> -		new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
> -			sizeof(struct zcopy_mbuf), 0, newnode);
> -		if (new_zmbuf) {
> -			rte_free(vq->zmbufs);
> -			vq->zmbufs = new_zmbuf;
> +		if (dev->dequeue_zero_copy) {
> +			new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
> +					sizeof(struct zcopy_mbuf), 0, newnode);
> +			if (new_zmbuf) {
> +				rte_free(vq->zmbufs);
> +				vq->zmbufs = new_zmbuf;
> +			}
>  		}
>  
>  		if (vq_is_packed(dev)) {
> -- 
> 2.17.1
> 

Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>

Thanks!

  reply	other threads:[~2018-08-16  5:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180815145341eucas1p15832e119a9d6f3fc54796675a283c44f@eucas1p1.samsung.com>
2018-08-15 14:54 ` [PATCH] vhost: fix zmbufs array leak after NUMA realloc Ilya Maximets
2018-08-16  5:31   ` Tiwei Bie [this message]
2018-09-10 13:38   ` Maxime Coquelin

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=20180816053108.GA8252@debian \
    --to=tiwei.bie@intel.com \
    --cc=dev@dpdk.org \
    --cc=i.maximets@samsung.com \
    --cc=junjie.j.chen@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    --cc=zhihong.wang@intel.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.