[PATCH 1/2] get_user_pages: fix possible page leak on oom

From: Oleg Nesterov
Date: Sat Jun 21 2008 - 09:39:43 EST


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@xxxxxxxxxx>

--- 26-rc2/mm/memory.c~1_GUP_OOM 2008-06-21 15:35:21.000000000 +0400
+++ 26-rc2/mm/memory.c 2008-06-21 15:56:58.000000000 +0400
@@ -1115,7 +1115,7 @@ int get_user_pages(struct task_struct *t
* 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;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/