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 <[email protected]> Signed-off-by: Jason Wang <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Gautam Dawar <[email protected]>
1 parent 1c96d54 commit 0b7a04a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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)