Skip to content

Commit 0b7a04a

Browse files
jasowangmstsirkin
authored andcommitted
vdpasim: fix memory leak when freeing IOTLBs
After commit bda324f ("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: bda324f ("vdpasim: control virtqueue support") Cc: Gautam Dawar <gautam.dawar@xilinx.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Message-Id: <20221213090717.61529-1-jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Gautam Dawar <gautam.dawar@amd.com>
1 parent 1c96d54 commit 0b7a04a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,9 @@ static void vdpasim_free(struct vdpa_device *vdpa)
689689
}
690690

691691
kvfree(vdpasim->buffer);
692-
vhost_iotlb_free(vdpasim->iommu);
692+
for (i = 0; i < vdpasim->dev_attr.nas; i++)
693+
vhost_iotlb_reset(&vdpasim->iommu[i]);
694+
kfree(vdpasim->iommu);
693695
kfree(vdpasim->vqs);
694696
kfree(vdpasim->config);
695697
}

0 commit comments

Comments
 (0)