From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
To: Li Qiang <liq3ea@163.com>, mst@redhat.com, jasowang@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: Fri, 18 Sep 2020 21:03:45 +0800 [thread overview]
Message-ID: <1104febd-1f2d-5edd-52e9-ca992e6d5340@linux.alibaba.com> (raw)
In-Reply-To: <20200909154120.363209-1-liq3ea@163.com>
LGTM.
Reviewed-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Thanks.
On 9/9/20 11:41 PM, 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;
> }
>
prev parent reply other threads:[~2020-09-18 13:03 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
2020-09-18 12:58 ` Li Qiang
2020-09-18 13:03 ` Tianjia Zhang [this message]
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=1104febd-1f2d-5edd-52e9-ca992e6d5340@linux.alibaba.com \
--to=tianjia.zhang@linux.alibaba.com \
--cc=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