All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 1/3] mm: fix pageref leak in do_swap_page()
@ 2009-04-20 20:24 ` Johannes Weiner
  0 siblings, 0 replies; 43+ messages in thread
From: Johannes Weiner @ 2009-04-20 20:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Balbir Singh

By the time the memory cgroup code is notified about a swapin we
already hold a reference on the fault page.

If the cgroup callback fails make sure to unlock AND release the page
or we leak the reference.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
---
 mm/memory.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 366dab5..db126b6 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2536,8 +2536,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
 
 	if (mem_cgroup_try_charge_swapin(mm, page, GFP_KERNEL, &ptr)) {
 		ret = VM_FAULT_OOM;
-		unlock_page(page);
-		goto out;
+		goto out_page;
 	}
 
 	/*
@@ -2599,6 +2598,7 @@ out:
 out_nomap:
 	mem_cgroup_cancel_charge_swapin(ptr);
 	pte_unmap_unlock(page_table, ptl);
+out_page:
 	unlock_page(page);
 	page_cache_release(page);
 	return ret;
-- 
1.6.2.1.135.gde769


^ permalink raw reply related	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2009-04-27  8:04 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-20 20:24 [patch 1/3] mm: fix pageref leak in do_swap_page() Johannes Weiner
2009-04-20 20:24 ` Johannes Weiner
2009-04-20 20:24 ` [patch 2/3][rfc] swap: try to reuse freed slots in the allocation area Johannes Weiner
2009-04-20 20:24   ` Johannes Weiner
2009-04-22 19:59   ` Hugh Dickins
2009-04-22 19:59     ` Hugh Dickins
2009-04-27  8:02     ` Johannes Weiner
2009-04-27  8:02       ` Johannes Weiner
2009-04-20 20:24 ` [patch 3/3][rfc] vmscan: batched swap slot allocation Johannes Weiner
2009-04-20 20:24   ` Johannes Weiner
2009-04-20 20:31   ` Johannes Weiner
2009-04-20 20:53     ` Andrew Morton
2009-04-20 20:53       ` Andrew Morton
2009-04-20 21:38       ` Johannes Weiner
2009-04-20 21:38         ` Johannes Weiner
2009-04-21  0:58   ` KAMEZAWA Hiroyuki
2009-04-21  0:58     ` KAMEZAWA Hiroyuki
2009-04-21  8:52     ` Johannes Weiner
2009-04-21  8:52       ` Johannes Weiner
2009-04-21  9:23       ` KAMEZAWA Hiroyuki
2009-04-21  9:23         ` KAMEZAWA Hiroyuki
2009-04-21  9:54         ` Johannes Weiner
2009-04-21  9:54           ` Johannes Weiner
2009-04-21  9:27       ` KOSAKI Motohiro
2009-04-21  9:27         ` KOSAKI Motohiro
2009-04-21  9:38         ` Johannes Weiner
2009-04-21  9:38           ` Johannes Weiner
2009-04-21  9:41           ` KOSAKI Motohiro
2009-04-21  9:41             ` KOSAKI Motohiro
2009-04-22 20:37   ` Hugh Dickins
2009-04-22 20:37     ` Hugh Dickins
2009-04-27  7:46     ` Johannes Weiner
2009-04-27  7:46       ` Johannes Weiner
2009-04-20 23:36 ` [patch 1/3] mm: fix pageref leak in do_swap_page() Minchan Kim
2009-04-20 23:36   ` Minchan Kim
2009-04-21  3:14 ` Balbir Singh
2009-04-21  3:14   ` Balbir Singh
2009-04-21  8:19   ` Johannes Weiner
2009-04-21  8:19     ` Johannes Weiner
2009-04-21  8:45     ` Balbir Singh
2009-04-21  8:45       ` Balbir Singh
2009-04-21  3:44 ` KAMEZAWA Hiroyuki
2009-04-21  3:44   ` KAMEZAWA Hiroyuki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.