[PATCH][RESEND] mm: fix uninitialized variables for find_vma_prepare callers

Previous thread: [PATCH] x86: pda_init: fix memory leak with CPU_HOTPLUG by Andreas Herrmann on Friday, August 1, 2008 - 10:36 am. (2 messages)

Next thread: POSIX_FADV_DONTNEED by Trevor Woollacott [ MTN - Innovation Centre ] on Friday, August 1, 2008 - 11:05 am. (5 messages)
To: LKML <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Friday, August 1, 2008 - 11:13 am

This was submitted for 2.6.26-rc8-mm1 but it must have gotten overlooked:

diff --git a/mm/mmap.c b/mm/mmap.c
index 4c5211b..3d65a03 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -372,7 +372,7 @@ find_vma_prepare(struct mm_struct *mm, unsigned long addr,
if (vma_tmp->vm_end > addr) {
vma = vma_tmp;
if (vma_tmp->vm_start <= addr)
- return vma;
+ break;
__rb_link = &__rb_parent->rb_left;
} else {
rb_prev = __rb_parent;
--

To: Ryan Hope <rmh3093@...>
Cc: Benny Halevy <bhalevy@...>, LKML <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Friday, August 1, 2008 - 1:31 pm

True, thanks, I guess that's my fault: it got stalled by me, because I
found it unsatisfying to fix the uninitialization from a compiler point
of view, whilst leaving it in an undefined state from a usability point
of view. But since nothing does use those fields in this case, and my
amateurish treephobic experiments didn't find a quick solution to that,
I guess this is an improvement which should go in.

But please, let's credit Benny who posted it, and give his explanation
of what the patch is for, with some additional comment from me. Which
leaves you out - "Reminded-by: Ryan Hope <rmh3093@gmail.com>"?

From: Benny Halevy <bhalevy@panasas.com>

gcc 4.3.0 correctly emits the following warnings.
When a vma covering addr is found, find_vma_prepare indeed returns without
setting pprev, rb_link, and rb_parent.

/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/mm/mmap.c: In function =E2=
=80=98insert_vm_struct=E2=80=99:
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/mm/mmap.c:2085: warning: =
=E2=80=98rb_parent=E2=80=99 may be used uninitialized in this function
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/mm/mmap.c:2085: warning: =
=E2=80=98rb_link=E2=80=99 may be used uninitialized in this function
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/mm/mmap.c:2084: warning: =
=E2=80=98prev=E2=80=99 may be used uninitialized in this function
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/mm/mmap.c: In function =E2=
=80=98copy_vma=E2=80=99:
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/mm/mmap.c:2124: warning: =
=E2=80=98rb_parent=E2=80=99 may be used uninitialized in this function
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/mm/mmap.c:2124: warning: =
=E2=80=98rb_link=E2=80=99 may be used uninitialized in this function
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/mm/mmap.c:2123: warning: =
=E2=80=98prev=E2=80=99 may be used uninitialized in this function
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/mm/mmap.c: In function =E2=
=80=98do_brk=E2=80=9...

To: Hugh Dickins <hugh@...>
Cc: Benny Halevy <bhalevy@...>, LKML <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Friday, August 1, 2008 - 2:08 pm

Yeah original author should get credit, i just didnt go back an look,
thanks for doing that.

--

To: LKML <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Friday, August 1, 2008 - 11:15 am

I forgot to mention that this patch is for 2.6.27-rc1-mm1...

-Ryan

--

Previous thread: [PATCH] x86: pda_init: fix memory leak with CPU_HOTPLUG by Andreas Herrmann on Friday, August 1, 2008 - 10:36 am. (2 messages)

Next thread: POSIX_FADV_DONTNEED by Trevor Woollacott [ MTN - Innovation Centre ] on Friday, August 1, 2008 - 11:05 am. (5 messages)