From: Hugh Dickins Date: Fri, 21 Sep 2012 00:57:17 +0000 (+1000) Subject: mm-mmapc-replace-find_vma_prepare-with-clearer-find_vma_links fix X-Git-Tag: next-20120925~1^2~321 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=36ea21dbe01e8ec8c6411c6a65b7eaaf2967d494;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 Cc: 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) {