aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2009-03-13 16:51:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-03-14 14:57:22 -0400
commit15e7b8767605dc0cb9bd4594caabfec392385210 (patch)
tree3826c146f7ecce8188d76d83c5bf2875e5890909
parent020fe22ff14320927f394de222cbb11708bcc7a8 (diff)
nommu: ramfs: don't leak pages when adding to page cache fails
When a ramfs nommu mapping is expanded, contiguous pages are allocated and added to the pagecache. The caller's reference is then passed on by moving whole pagevecs to the file lru list. If the page cache adding fails, make sure that the error path also moves the pagevec contents which might still contain up to PAGEVEC_SIZE successfully added pages, of which we would leak references otherwise. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Cc: David Howells <dhowells@redhat.com> Cc: Enrik Berkhan <Enrik.Berkhan@ge.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/ramfs/file-nommu.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 90d72bead55b..5d7c7ececa64 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -129,6 +129,7 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
129 return -EFBIG; 129 return -EFBIG;
130 130
131 add_error: 131 add_error:
132 pagevec_lru_add_file(&lru_pvec);
132 page_cache_release(pages + loop); 133 page_cache_release(pages + loop);
133 for (loop++; loop < npages; loop++) 134 for (loop++; loop < npages; loop++)
134 __free_page(pages + loop); 135 __free_page(pages + loop);