From: Hugh Dickins Date: Thu, 13 Sep 2012 00:58:31 +0000 (+1000) Subject: mm-mmapc-replace-find_vma_prepare-with-clearer-find_vma_links fix X-Git-Tag: next-20120919~1^2~219 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3c8aa11cfdf24ff7b73ddf3f69ccbaea99522b7e;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 07ae3776866b..7f408ab38f72 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2352,7 +2352,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) {