From 3c8aa11cfdf24ff7b73ddf3f69ccbaea99522b7e Mon Sep 17 00:00:00 2001 From: Hugh Dickins Date: Thu, 13 Sep 2012 10:58:31 +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 Cc: 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 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) { -- 2.39.5