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 <oleg@tv-sign.ru>
Acked-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Oleg Nesterov 2008-07-04 09:59:28 -07:00 committed by Linus Torvalds
parent 7ca796f492
commit 7a36a752d0
1 changed files with 1 additions and 1 deletions

View File

@ -1151,7 +1151,7 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
* be processed until returning to user space. * be processed until returning to user space.
*/ */
if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE))) if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE)))
return -ENOMEM; return i ? i : -ENOMEM;
if (write) if (write)
foll_flags |= FOLL_WRITE; foll_flags |= FOLL_WRITE;