Skip to content

Commit

Permalink
vdpasim: fix memory leak when freeing IOTLBs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jason Wang authored and Michael S. Tsirkin committed Dec 28, 2022
1 parent 1c96d54 commit 0b7a04a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/vdpa/vdpa_sim/vdpa_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 0b7a04a

Please sign in to comment.