All of lore.kernel.org
 help / color / mirror / Atom feed
* + nommu-fix-error-handling-in-do_mmap_pgoff.patch added to -mm tree
@ 2009-09-02 21:48 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2009-09-02 21:48 UTC (permalink / raw)
  To: mm-commits; +Cc: dhowells, gerg, lethal, mel, penberg


The patch titled
     nommu: fix error handling in do_mmap_pgoff()
has been added to the -mm tree.  Its filename is
     nommu-fix-error-handling-in-do_mmap_pgoff.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
out what to do about this

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: nommu: fix error handling in do_mmap_pgoff()
From: David Howells <dhowells@redhat.com>

Fix the error handling in do_mmap_pgoff().  If do_mmap_shared_file() or
do_mmap_private() fail, we jump to the error_put_region label at which
point we cann __put_nommu_region() on the region - but we haven't yet
added the region to the tree, and so __put_nommu_region() may BUG
because the region tree is empty or it may corrupt the region tree.

To get around this, we can afford to add the region to the region tree
before calling do_mmap_shared_file() or do_mmap_private() as we keep
nommu_region_sem write-locked, so no-one can race with us by seeing a
transient region.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Greg Ungerer <gerg@snapgear.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/nommu.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -puN mm/nommu.c~nommu-fix-error-handling-in-do_mmap_pgoff mm/nommu.c
--- a/mm/nommu.c~nommu-fix-error-handling-in-do_mmap_pgoff
+++ a/mm/nommu.c
@@ -1352,6 +1352,7 @@ unsigned long do_mmap_pgoff(struct file 
 	}
 
 	vma->vm_region = region;
+	add_nommu_region(region);
 
 	/* set up the mapping */
 	if (file && vma->vm_flags & VM_SHARED)
@@ -1361,8 +1362,6 @@ unsigned long do_mmap_pgoff(struct file 
 	if (ret < 0)
 		goto error_put_region;
 
-	add_nommu_region(region);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-02 21:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-02 21:48 + nommu-fix-error-handling-in-do_mmap_pgoff.patch added to -mm tree akpm

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.