aboutsummaryrefslogtreecommitdiffstats
path: root/mm/nommu.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2009-10-30 09:13:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-10-31 15:11:37 -0400
commit89a8640279f8bb78aaf778d1fc5c4a6778f18064 (patch)
treec768adbc88d0482d4fdd0ff8385fe77c01ae1534 /mm/nommu.c
parent2e2ec952350f25242f2e0539db16b1e46f9eb01b (diff)
NOMMU: Don't pass NULL pointers to fput() in do_mmap_pgoff()
Don't pass NULL pointers to fput() in the error handling paths of the NOMMU do_mmap_pgoff() as it can't handle it. The following can be used as a test program: int main() { static long long a[1024 * 1024 * 20] = { 0 }; return a;} Without the patch, the code oopses in atomic_long_dec_and_test() as called by fput() after the kernel complains that it can't allocate that big a chunk of memory. With the patch, the kernel just complains about the allocation size and then the program segfaults during execve() as execve() can't complete the allocation of all the new ELF program segments. Reported-by: Robin Getz <rgetz@blackfin.uclinux.org> Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Robin Getz <rgetz@blackfin.uclinux.org> Cc: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/nommu.c')
-rw-r--r--mm/nommu.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mm/nommu.c b/mm/nommu.c
index 5189b5aed8c0..9876fa0c3ad3 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1362,9 +1362,11 @@ share:
1362error_just_free: 1362error_just_free:
1363 up_write(&nommu_region_sem); 1363 up_write(&nommu_region_sem);
1364error: 1364error:
1365 fput(region->vm_file); 1365 if (region->vm_file)
1366 fput(region->vm_file);
1366 kmem_cache_free(vm_region_jar, region); 1367 kmem_cache_free(vm_region_jar, region);
1367 fput(vma->vm_file); 1368 if (vma->vm_file)
1369 fput(vma->vm_file);
1368 if (vma->vm_flags & VM_EXECUTABLE) 1370 if (vma->vm_flags & VM_EXECUTABLE)
1369 removed_exe_file_vma(vma->vm_mm); 1371 removed_exe_file_vma(vma->vm_mm);
1370 kmem_cache_free(vm_area_cachep, vma); 1372 kmem_cache_free(vm_area_cachep, vma);