Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vdpa_sim: cleanup kiovs in vdpasim_free()

vringh_getdesc_iotlb() allocates memory to store the kvec, that
is freed with vringh_kiov_cleanup().

vringh_getdesc_iotlb() is able to reuse a kvec previously allocated,
so in order to avoid to allocate the kvec for each request, we are
not calling vringh_kiov_cleanup() when we finished to handle a
request, but we should call it when we free the entire device.

Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210315163450.254396-8-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Stefano Garzarella and committed by
Michael S. Tsirkin
bc433e5e 14c9ac05

+7
+7
drivers/vdpa/vdpa_sim/vdpa_sim.c
··· 562 562 static void vdpasim_free(struct vdpa_device *vdpa) 563 563 { 564 564 struct vdpasim *vdpasim = vdpa_to_sim(vdpa); 565 + int i; 565 566 566 567 cancel_work_sync(&vdpasim->work); 568 + 569 + for (i = 0; i < vdpasim->dev_attr.nvqs; i++) { 570 + vringh_kiov_cleanup(&vdpasim->vqs[i].out_iov); 571 + vringh_kiov_cleanup(&vdpasim->vqs[i].in_iov); 572 + } 573 + 567 574 put_iova_domain(&vdpasim->iova); 568 575 iova_cache_put(); 569 576 kvfree(vdpasim->buffer);