diff options
author | Jason Wang <[email protected]> | 2022-12-13 17:07:17 +0800 |
---|---|---|
committer | Michael S. Tsirkin <[email protected]> | 2022-12-28 05:28:11 -0500 |
commit | 0b7a04a30eef20e6b24926a45c0ce7906ae85bd6 (patch) | |
tree | d34281cd5de6ee12155f7ad509d76d854a3e562c | |
parent | 1c96d5457f7251d1c62aacc04921557d56fc049a (diff) |
vdpasim: fix memory leak when freeing IOTLBs
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 <[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]>
-rw-r--r-- | drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index b20689f8fe89..cb88891b44a8 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -689,7 +689,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); } |