{
        unsigned long i;
        bool drain_allow = true;
-       bool migrate_allow = true;
        LIST_HEAD(cma_page_list);
        long ret = nr_pages;
        struct page *prev_head, *head;
                        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)) {
-                       /*
-                        * some of the pages failed migration. Do get_user_pages
-                        * without migration.
-                        */
-                       migrate_allow = false;
-
+               ret = migrate_pages(&cma_page_list, alloc_migration_target,
+                                   NULL, (unsigned long)&mtc, MIGRATE_SYNC,
+                                   MR_CONTIG_RANGE);
+               if (ret) {
                        if (!list_empty(&cma_page_list))
                                putback_movable_pages(&cma_page_list);
+                       return ret > 0 ? -ENOMEM : ret;
                }
+
                /*
                 * We did migrate all the pages, Try to get the page references
                 * again migrating any new CMA pages which we failed to isolate
                                                   pages, vmas, NULL,
                                                   gup_flags);
 
-               if ((ret > 0) && migrate_allow) {
+               if (ret > 0) {
                        nr_pages = ret;
                        drain_allow = true;
                        goto check_again;