]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - mm/gup.c
mm/gup: use unpin_user_pages() in __gup_longterm_locked()
[mirror_ubuntu-jammy-kernel.git] / mm / gup.c
index 102877ed77a4b42af7e0a625cfc4b79791494f95..98eb8e6d2609c32efec9a1fe21840149140354fa 100644 (file)
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1647,8 +1647,11 @@ check_again:
                /*
                 * drop the above get_user_pages reference.
                 */
-               for (i = 0; i < nr_pages; i++)
-                       put_page(pages[i]);
+               if (gup_flags & FOLL_PIN)
+                       unpin_user_pages(pages, nr_pages);
+               else
+                       for (i = 0; i < nr_pages; i++)
+                               put_page(pages[i]);
 
                if (migrate_pages(&cma_page_list, alloc_migration_target, NULL,
                        (unsigned long)&mtc, MIGRATE_SYNC, MR_CONTIG_RANGE)) {
@@ -1728,8 +1731,11 @@ static long __gup_longterm_locked(struct mm_struct *mm,
                        goto out;
 
                if (check_dax_vmas(vmas_tmp, rc)) {
-                       for (i = 0; i < rc; i++)
-                               put_page(pages[i]);
+                       if (gup_flags & FOLL_PIN)
+                               unpin_user_pages(pages, rc);
+                       else
+                               for (i = 0; i < rc; i++)
+                                       put_page(pages[i]);
                        rc = -EOPNOTSUPP;
                        goto out;
                }