nommu: ramfs: don't leak pages when adding to page cache fails

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Saturday, March 14, 2009 - 12:59 pm

Gitweb:     http://git.kernel.org/linus/15e7b8767605dc0cb9bd4594caabfec392385210
Commit:     15e7b8767605dc0cb9bd4594caabfec392385210
Parent:     020fe22ff14320927f394de222cbb11708bcc7a8
Author:     Johannes Weiner <hannes@cmpxchg.org>
AuthorDate: Fri Mar 13 13:51:58 2009 -0700
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Sat Mar 14 11:57:22 2009 -0700

    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>
---
 fs/ramfs/file-nommu.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 90d72be..5d7c7ec 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)
 	return -EFBIG;
 
  add_error:
+	pagevec_lru_add_file(&lru_pvec);
 	page_cache_release(pages + loop);
 	for (loop++; loop < npages; loop++)
 		__free_page(pages + loop);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
nommu: ramfs: don't leak pages when adding to page cache fails, Linux Kernel Mailing ..., (Sat Mar 14, 12:59 pm)