From: Oleg Nesterov Date: Fri, 4 Jul 2008 16:59:28 +0000 (-0700) Subject: get_user_pages(): fix possible page leak on oom X-Git-Tag: firefly_0821_release~19823 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7a36a752d006f6874049da510297eeb7f09d92a7;p=firefly-linux-kernel-4.4.55.git get_user_pages(): fix possible page leak on oom get_user_pages() must not return the error when i != 0. When pages != NULL we have i get_page()'ed pages. Signed-off-by: Oleg Nesterov Acked-by: Nick Piggin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memory.c b/mm/memory.c index 350e646032f5..2302d228fe04 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1151,7 +1151,7 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, * be processed until returning to user space. */ if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE))) - return -ENOMEM; + return i ? i : -ENOMEM; if (write) foll_flags |= FOLL_WRITE;