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

Configure Feed

Select the types of activity you want to include in your feed.

iommufd: viommu: free memory allocated by kvcalloc() using kvfree()

Use kvfree() instead of kfree() to free pages allocated by kvcalloc()
in iommufs_hw_queue_alloc_phys() to fix potential memory corruption.
Ensure the memory is properly freed, as kvcalloc may internally use
vmalloc or kmalloc depending on available memory in the system.

Fixes: 2238ddc2b056 ("iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl")
Link: https://patch.msgid.link/r/aJifyVV2PL6WGEs6@bhairav-test.ee.iitb.ac.in
Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Akhilesh Patil and committed by
Jason Gunthorpe
8fe8a092 c17b750b

+2 -2
+2 -2
drivers/iommu/iommufd/viommu.c
··· 339 339 } 340 340 341 341 *base_pa = (page_to_pfn(pages[0]) << PAGE_SHIFT) + offset; 342 - kfree(pages); 342 + kvfree(pages); 343 343 return access; 344 344 345 345 out_unpin: ··· 349 349 out_destroy: 350 350 iommufd_access_destroy_internal(viommu->ictx, access); 351 351 out_free: 352 - kfree(pages); 352 + kvfree(pages); 353 353 return ERR_PTR(rc); 354 354 } 355 355