lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1104febd-1f2d-5edd-52e9-ca992e6d5340@linux.alibaba.com>
Date:   Fri, 18 Sep 2020 21:03:45 +0800
From:   Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>
To:     Li Qiang <liq3ea@....com>, mst@...hat.com, jasowang@...hat.com
Cc:     kvm@...r.kernel.org, virtualization@...ts.linux-foundation.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        liq3ea@...il.com
Subject: Re: [PATCH] vhost-vdpa: fix memory leak in error path

LGTM.

Reviewed-by: Tianjia Zhang <tianjia.zhang@...ux.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@....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;
>   }
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ