mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Li Qiang <liq3ea@163.com>, mst@redhat.com
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	liq3ea@gmail.com
Subject: Re: [PATCH] vhost-vdpa: fix memory leak in error path
Date: Thu, 10 Sep 2020 09:56:05 +0800	[thread overview]
Message-ID: <bfae5c35-355a-8d8a-5057-a970db24ee41@redhat.com> (raw)
In-Reply-To: <20200909154120.363209-1-liq3ea@163.com>


On 2020/9/9 下午11:41, Li Qiang wrote:
> Free the 'page_list' when the 'npages' is zero.
>
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>   drivers/vhost/vdpa.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 3fab94f88894..6a9fcaf1831d 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -609,8 +609,10 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
>   		gup_flags |= FOLL_WRITE;
>   
>   	npages = PAGE_ALIGN(msg->size + (iova & ~PAGE_MASK)) >> PAGE_SHIFT;
> -	if (!npages)
> -		return -EINVAL;
> +	if (!npages) {
> +		ret = -EINVAL;
> +		goto free_page;
> +	}
>   
>   	mmap_read_lock(dev->mm);
>   
> @@ -666,6 +668,8 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
>   		atomic64_sub(npages, &dev->mm->pinned_vm);
>   	}
>   	mmap_read_unlock(dev->mm);
> +
> +free_page:
>   	free_page((unsigned long)page_list);
>   	return ret;
>   }


Cc: stable@vger.kernel.org

Acked-by: Jason Wang <jasowang@redhat.com>




  reply	other threads:[~2020-09-10  2:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09 15:41 Li Qiang
2020-09-10  1:56 ` Jason Wang [this message]
2020-09-18 12:58 ` Li Qiang
2020-09-18 13:03 ` Tianjia Zhang

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=bfae5c35-355a-8d8a-5057-a970db24ee41@redhat.com \
    --to=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liq3ea@163.com \
    --cc=liq3ea@gmail.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome