All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vdpasim: fix memory leak when freeing IOTLBs
@ 2022-12-13  9:07 ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2022-12-13  9:07 UTC (permalink / raw)
  To: mst, jasowang; +Cc: gautam.dawar, linux-kernel, virtualization

After commit bda324fd037a ("vdpasim: control virtqueue support"),
vdpasim->iommu became an array of IOTLB, so we should clean the
mappings of each free one by one instead of just deleting the ranges
in the first IOTLB which may leak maps.

Fixes: bda324fd037a ("vdpasim: control virtqueue support")
Cc: Gautam Dawar <gautam.dawar@xilinx.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index b071f0d842fb..9668dc477843 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -690,7 +690,9 @@ static void vdpasim_free(struct vdpa_device *vdpa)
 	}
 
 	kvfree(vdpasim->buffer);
-	vhost_iotlb_free(vdpasim->iommu);
+	for (i = 0; i < vdpasim->dev_attr.nas; i++)
+		vhost_iotlb_reset(&vdpasim->iommu[i]);
+	kfree(vdpasim->iommu);
 	kfree(vdpasim->vqs);
 	kfree(vdpasim->config);
 }
-- 
2.25.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] vdpasim: fix memory leak when freeing IOTLBs
@ 2022-12-13  9:07 ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2022-12-13  9:07 UTC (permalink / raw)
  To: mst, jasowang; +Cc: gautam.dawar, virtualization, linux-kernel

After commit bda324fd037a ("vdpasim: control virtqueue support"),
vdpasim->iommu became an array of IOTLB, so we should clean the
mappings of each free one by one instead of just deleting the ranges
in the first IOTLB which may leak maps.

Fixes: bda324fd037a ("vdpasim: control virtqueue support")
Cc: Gautam Dawar <gautam.dawar@xilinx.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index b071f0d842fb..9668dc477843 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -690,7 +690,9 @@ static void vdpasim_free(struct vdpa_device *vdpa)
 	}
 
 	kvfree(vdpasim->buffer);
-	vhost_iotlb_free(vdpasim->iommu);
+	for (i = 0; i < vdpasim->dev_attr.nas; i++)
+		vhost_iotlb_reset(&vdpasim->iommu[i]);
+	kfree(vdpasim->iommu);
 	kfree(vdpasim->vqs);
 	kfree(vdpasim->config);
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] vdpasim: fix memory leak when freeing IOTLBs
  2022-12-13  9:07 ` Jason Wang
  (?)
@ 2022-12-13 11:08 ` Gautam Dawar
  -1 siblings, 0 replies; 3+ messages in thread
From: Gautam Dawar @ 2022-12-13 11:08 UTC (permalink / raw)
  To: Jason Wang, mst; +Cc: gautam.dawar, virtualization, linux-kernel


On 12/13/22 14:37, Jason Wang wrote:
> CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.
>
>
> After commit bda324fd037a ("vdpasim: control virtqueue support"),
> vdpasim->iommu became an array of IOTLB, so we should clean the
> mappings of each free one by one instead of just deleting the ranges
> in the first IOTLB which may leak maps.
>
> Fixes: bda324fd037a ("vdpasim: control virtqueue support")
> Cc: Gautam Dawar <gautam.dawar@xilinx.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>   drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> index b071f0d842fb..9668dc477843 100644
> --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> @@ -690,7 +690,9 @@ static void vdpasim_free(struct vdpa_device *vdpa)
>          }
>
>          kvfree(vdpasim->buffer);
> -       vhost_iotlb_free(vdpasim->iommu);
> +       for (i = 0; i < vdpasim->dev_attr.nas; i++)
> +               vhost_iotlb_reset(&vdpasim->iommu[i]);
> +       kfree(vdpasim->iommu);
>          kfree(vdpasim->vqs);
>          kfree(vdpasim->config);
>   }
> --
> 2.25.1
>
Looks good to me.

Reviewed-by: Gautam Dawar <gautam.dawar@amd.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-13 11:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13  9:07 [PATCH] vdpasim: fix memory leak when freeing IOTLBs Jason Wang
2022-12-13  9:07 ` Jason Wang
2022-12-13 11:08 ` Gautam Dawar

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.