From: Hugh Dickins Date: Wed, 26 Sep 2012 01:33:14 +0000 (+1000) Subject: mm-mmapc-replace-find_vma_prepare-with-clearer-find_vma_links fix X-Git-Tag: next-20120927~1^2~339 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=74a4c8c03b25adf7e535b329e3b0714a96dc765e;p=karo-tx-linux.git mm-mmapc-replace-find_vma_prepare-with-clearer-find_vma_links fix 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 Cc: Benny Halevy Cc: Hillf Danton Tested-by: David Rientjes Signed-off-by: Andrew Morton --- diff --git a/mm/mmap.c b/mm/mmap.c index 7dc1bffdb66b..2ba27434e843 100644 --- 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) {