From 16f400ab056684dd37a1449c45aebc195243452a Mon Sep 17 00:00:00 2001 From: Hugh Dickins Date: Fri, 28 Sep 2012 10:19:08 +1000 Subject: [PATCH] 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 --- mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { -- 2.39.5