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@xxxxxxxxxx> 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@xxxxxxxxxx> Acked-by: Pekka Enberg <penberg@xxxxxxxxxxxxxx> Acked-by: Paul Mundt <lethal@xxxxxxxxxxxx> Cc: Mel Gorman <mel@xxxxxxxxx> Cc: Greg Ungerer <gerg@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- 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); - /* okay... we have a mapping; now we have to register it */ result = vma->vm_start; _ Patches currently in -mm which might be from dhowells@xxxxxxxxxx are nommu-fix-error-handling-in-do_mmap_pgoff.patch linux-next.patch waitqueues-give-waitqueue-spinlocks-their-own-lockdep-classes-checkpatch-fixes.patch mm-count-only-reclaimable-lru-pages-v2.patch arches-drop-superfluous-casts-in-nr_free_pages-callers.patch mm-includecheck-fix-for-mm-nommuc.patch frv-duplicate-output_buffer-of-e03.patch frv-convert-to-asm-generic-hardirqh.patch misc-remove-redundant-start_kernel-prototypes.patch do_wait-wakeup-optimization-change-__wake_up_parent-to-use-filtered-wakeup-selinux_bprm_committed_creds-use-__wake_up_parent.patch elf-clean-up-fill_note_info.patch elf-clean-up-fill_note_info-fix.patch fdpic-ignore-the-loaders-pt_gnu_stack-when-calculating-the-stack-size.patch flat-use-is_err_value-helper-macro.patch sysctl-remove-struct-file-argument-of-proc_handler.patch mutex-subsystem-synchro-test-module.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html