Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/fremap.c: fix possible oops on error path

The vm_flags introduced in 6d7825b10dbe ("mm/fremap.c: fix oops on error
path") is supposed to avoid a compiler warning about unitialized
vm_flags without changing the generated code.

However I am concerned that this is going to be very brittle, and fail
with some compiler versions. The failure could be either of:

- compiler could actually load vma->vm_flags before checking for the
!vma condition, thus reintroducing the oops

- compiler could optimize out the !vma check, since the pointer just got
dereferenced shortly before (so the compiler knows it can't be NULL!)

I propose reversing this part of the change and initializing vm_flags to 0
just to avoid the bogus uninitialized use warning.

Signed-off-by: Michel Lespinasse <walken@google.com>
Cc: Tommi Rantala <tt.rantala@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Michel Lespinasse and committed by
Linus Torvalds
a2362d24 f4846e52

+2 -3
+2 -3
mm/fremap.c
··· 129 129 struct vm_area_struct *vma; 130 130 int err = -EINVAL; 131 131 int has_write_lock = 0; 132 - vm_flags_t vm_flags; 132 + vm_flags_t vm_flags = 0; 133 133 134 134 if (prot) 135 135 return err; ··· 163 163 * and that the remapped range is valid and fully within 164 164 * the single existing vma. 165 165 */ 166 - vm_flags = vma->vm_flags; 167 - if (!vma || !(vm_flags & VM_SHARED)) 166 + if (!vma || !(vma->vm_flags & VM_SHARED)) 168 167 goto out; 169 168 170 169 if (!vma->vm_ops || !vma->vm_ops->remap_pages)