The patch titled Subject: mm/gup.c: allow CMA migration to propagate errors back to caller has been added to the -mm tree. Its filename is mm-gup-allow-cma-migration-to-propagate-errors-back-to-caller.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-gup-allow-cma-migration-to-propagate-errors-back-to-caller.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-gup-allow-cma-migration-to-propagate-errors-back-to-caller.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: zhong jiang <zhongjiang@xxxxxxxxxx> Subject: mm/gup.c: allow CMA migration to propagate errors back to caller check_and_migrate_cma_pages() was recording the result of __get_user_pages_locked() in an unsigned "nr_pages" variable. Because __get_user_pages_locked() returns a signed value that can include negative errno values, this had the effect of hiding errors. Change check_and_migrate_cma_pages() implementation so that it uses a signed variable instead, and propagates the results back to the caller just as other gup internal functions do. This was discovered with the help of unsigned_lesser_than_zero.cocci. Link: http://lkml.kernel.org/r/1571671030-58029-1-git-send-email-zhongjiang@xxxxxxxxxx Signed-off-by: zhong jiang <zhongjiang@xxxxxxxxxx> Suggested-by: John Hubbard <jhubbard@xxxxxxxxxx> Acked-by: Vlastimil Babka <vbabka@xxxxxxx> Reviewed-by: John Hubbard <jhubbard@xxxxxxxxxx> Reviewed-by: Ira Weiny <ira.weiny@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/gup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/mm/gup.c~mm-gup-allow-cma-migration-to-propagate-errors-back-to-caller +++ a/mm/gup.c @@ -1443,6 +1443,7 @@ static long check_and_migrate_cma_pages( bool drain_allow = true; bool migrate_allow = true; LIST_HEAD(cma_page_list); + long ret = nr_pages; check_again: for (i = 0; i < nr_pages;) { @@ -1504,17 +1505,18 @@ check_again: * again migrating any new CMA pages which we failed to isolate * earlier. */ - nr_pages = __get_user_pages_locked(tsk, mm, start, nr_pages, + ret = __get_user_pages_locked(tsk, mm, start, nr_pages, pages, vmas, NULL, gup_flags); - if ((nr_pages > 0) && migrate_allow) { + if ((ret > 0) && migrate_allow) { + nr_pages = ret; drain_allow = true; goto check_again; } } - return nr_pages; + return ret; } #else static long check_and_migrate_cma_pages(struct task_struct *tsk, _ Patches currently in -mm which might be from zhongjiang@xxxxxxxxxx are mm-gup-allow-cma-migration-to-propagate-errors-back-to-caller.patch