On Sun, Aug 21, 2022 at 04:51:34PM +0300, Oded Gabbay wrote:
+static void vfio_pci_dma_buf_unmap(struct dma_buf_attachment *attachment,
struct sg_table *sgt,
enum dma_data_direction dir)
+{
struct vfio_pci_dma_buf *priv = attachment->dmabuf->priv;
dma_unmap_resource(attachment->dev, sg_dma_address(sgt->sgl),
priv->dmabuf->size, dir, DMA_ATTR_SKIP_CPU_SYNC);
sg_free_table(sgt);
Before calling sg_free_table(), you need to restore the orig_nents as it is used in that function to free the allocated memory of the sgt.
Oops, right, thanks good catch
Jason