Skip to content

Commit 09c091f

Browse files
tobluxjgunthorpe
authored andcommitted
iommufd/selftest: Fix page leaks in mock_viommu_{init,destroy}
mock_viommu_init() allocates two pages using __get_free_pages(..., 1), but its error path and mock_viommu_destroy() only release the first page using free_page(), leaking the second page. Use free_pages() with the matching order instead to avoid any page leaks. Fixes: 80478a2 ("iommufd/selftest: Add coverage for the new mmap interface") Link: https://patch.msgid.link/r/20260312164040.457293-3-thorsten.blum@linux.dev Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Pranjal Shrivastava <praan@google.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 7147ec8 commit 09c091f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/iommu/iommufd/selftest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ static void mock_viommu_destroy(struct iommufd_viommu *viommu)
636636
if (mock_viommu->mmap_offset)
637637
iommufd_viommu_destroy_mmap(&mock_viommu->core,
638638
mock_viommu->mmap_offset);
639-
free_page((unsigned long)mock_viommu->page);
639+
free_pages((unsigned long)mock_viommu->page, 1);
640640
mutex_destroy(&mock_viommu->queue_mutex);
641641

642642
/* iommufd core frees mock_viommu and viommu */
@@ -870,7 +870,7 @@ static int mock_viommu_init(struct iommufd_viommu *viommu,
870870
iommufd_viommu_destroy_mmap(&mock_viommu->core,
871871
mock_viommu->mmap_offset);
872872
err_free_page:
873-
free_page((unsigned long)mock_viommu->page);
873+
free_pages((unsigned long)mock_viommu->page, 1);
874874
return rc;
875875
}
876876

0 commit comments

Comments
 (0)