]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm-mmapc-replace-find_vma_prepare-with-clearer-find_vma_links fix
authorHugh Dickins <hughd@google.com>
Fri, 28 Sep 2012 00:19:08 +0000 (10:19 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 4 Oct 2012 05:03:11 +0000 (15:03 +1000)
Strangely, I can no longer get an uninitialized variable warning out of
copy_vma(), with or without the BUG() there; but David Rientjes gets it
when he builds with CONFIG_BUG off, which is understandable.

uninitialized_var() can be a useful tool, but I do prefer to avoid it:
partly because it might hide future errors, partly because I misspell it,
but mainly because the need for it comes and goes so mysteriously.

Given David's preference for no warning, mine for no uninitialized_var,
and Linus's for renaming BUG() to I_AM_A_MORON() to discourage its use in
the first place: copy_vma() seems a prime candidate for returning failure
to mremap instead of crashing the system.

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Benny Halevy <bhalevy@tonian.com>
Cc: Hillf Danton <dhillf@gmail.com>
Tested-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mmap.c

index 7dc1bffdb66bca3ddf99450ff37633bfd17b5c06..2ba27434e8437be250413f1923e62179280d3099 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2351,7 +2351,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
        }
 
        if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent))
-               BUG();
+               return NULL;    /* should never get here */
        new_vma = vma_merge(mm, prev, addr, addr + len, vma->vm_flags,
                        vma->anon_vma, vma->vm_file, pgoff, vma_policy(vma));
        if (new_vma) {