Skip to content

Commit 725f3f3

Browse files
committed
Merge tag 'vfio-v6.0-rc5' of https://github.com/awilliam/linux-vfio
Pull VFIO fix from Alex Williamson: - Fix zero page refcount leak (Alex Williamson) * tag 'vfio-v6.0-rc5' of https://github.com/awilliam/linux-vfio: vfio/type1: Unpin zero pages
2 parents 83dfc0e + 873aefb commit 725f3f3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/vfio/vfio_iommu_type1.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,18 @@ static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr,
558558
ret = pin_user_pages_remote(mm, vaddr, npages, flags | FOLL_LONGTERM,
559559
pages, NULL, NULL);
560560
if (ret > 0) {
561+
int i;
562+
563+
/*
564+
* The zero page is always resident, we don't need to pin it
565+
* and it falls into our invalid/reserved test so we don't
566+
* unpin in put_pfn(). Unpin all zero pages in the batch here.
567+
*/
568+
for (i = 0 ; i < ret; i++) {
569+
if (unlikely(is_zero_pfn(page_to_pfn(pages[i]))))
570+
unpin_user_page(pages[i]);
571+
}
572+
561573
*pfn = page_to_pfn(pages[0]);
562574
goto done;
563575
}

0 commit comments

Comments
 (0)