diff mbox series

vfio/iommu_type1: replace kfree with kvfree

Message ID 20211212091600.2560-1-billsjc@sjtu.edu.cn (mailing list archive)
State New, archived
Headers show
Series vfio/iommu_type1: replace kfree with kvfree | expand

Commit Message

Jiacheng Shi Dec. 12, 2021, 9:16 a.m. UTC
Variables allocated by kvzalloc should not be freed by kfree.
Because they may be allocated by vmalloc.
So we replace kfree with kvfree here.

Fixes: d6a4c185660c ("vfio iommu: Implementation of ioctl for dirty pages tracking")
Signed-off-by: Jiacheng Shi <billsjc@sjtu.edu.cn>
---
 drivers/vfio/vfio_iommu_type1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Williamson Dec. 21, 2021, 8:05 p.m. UTC | #1
On Sun, 12 Dec 2021 01:16:00 -0800
Jiacheng Shi <billsjc@sjtu.edu.cn> wrote:

> Variables allocated by kvzalloc should not be freed by kfree.
> Because they may be allocated by vmalloc.
> So we replace kfree with kvfree here.
> 
> Fixes: d6a4c185660c ("vfio iommu: Implementation of ioctl for dirty pages tracking")
> Signed-off-by: Jiacheng Shi <billsjc@sjtu.edu.cn>
> ---
>  drivers/vfio/vfio_iommu_type1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index f17490ab238f..9394aa9444c1 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -256,7 +256,7 @@ static int vfio_dma_bitmap_alloc(struct vfio_dma *dma, size_t pgsize)
>  
>  static void vfio_dma_bitmap_free(struct vfio_dma *dma)
>  {
> -	kfree(dma->bitmap);
> +	kvfree(dma->bitmap);
>  	dma->bitmap = NULL;
>  }
>  

Looks good to me, applied to vfio next branch for v5.17.  Thanks,

Alex
diff mbox series

Patch

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index f17490ab238f..9394aa9444c1 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -256,7 +256,7 @@  static int vfio_dma_bitmap_alloc(struct vfio_dma *dma, size_t pgsize)
 
 static void vfio_dma_bitmap_free(struct vfio_dma *dma)
 {
-	kfree(dma->bitmap);
+	kvfree(dma->bitmap);
 	dma->bitmap = NULL;
 }