* [PATCH] vhost-vdpa: fix memory leak in error path
@ 2020-09-09 15:41 Li Qiang
2020-09-10 1:56 ` Jason Wang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Li Qiang @ 2020-09-09 15:41 UTC (permalink / raw)
To: mst, jasowang; +Cc: kvm, virtualization, netdev, linux-kernel, liq3ea, Li Qiang
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;
}
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vhost-vdpa: fix memory leak in error path
2020-09-09 15:41 [PATCH] vhost-vdpa: fix memory leak in error path Li Qiang
@ 2020-09-10 1:56 ` Jason Wang
2020-09-18 12:58 ` Li Qiang
2020-09-18 13:03 ` Tianjia Zhang
2 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2020-09-10 1:56 UTC (permalink / raw)
To: Li Qiang, mst; +Cc: kvm, virtualization, netdev, linux-kernel, liq3ea
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vhost-vdpa: fix memory leak in error path
2020-09-09 15:41 [PATCH] vhost-vdpa: fix memory leak in error path Li Qiang
2020-09-10 1:56 ` Jason Wang
@ 2020-09-18 12:58 ` Li Qiang
2020-09-18 13:03 ` Tianjia Zhang
2 siblings, 0 replies; 4+ messages in thread
From: Li Qiang @ 2020-09-18 12:58 UTC (permalink / raw)
To: Li Qiang
Cc: Michael S. Tsirkin, Jason Wang, kvm list, virtualization, netdev,
linux-kernel
Any status update?
Thanks,
Li Qiang
Li Qiang <liq3ea@163.com> 于2020年9月9日周三 下午11:42写道:
>
> 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;
> }
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vhost-vdpa: fix memory leak in error path
2020-09-09 15:41 [PATCH] vhost-vdpa: fix memory leak in error path Li Qiang
2020-09-10 1:56 ` Jason Wang
2020-09-18 12:58 ` Li Qiang
@ 2020-09-18 13:03 ` Tianjia Zhang
2 siblings, 0 replies; 4+ messages in thread
From: Tianjia Zhang @ 2020-09-18 13:03 UTC (permalink / raw)
To: Li Qiang, mst, jasowang; +Cc: kvm, virtualization, netdev, linux-kernel, liq3ea
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;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-18 13:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 15:41 [PATCH] vhost-vdpa: fix memory leak in error path Li Qiang
2020-09-10 1:56 ` Jason Wang
2020-09-18 12:58 ` Li Qiang
2020-09-18 13:03 ` Tianjia Zhang
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