]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
remap_file_pages: correctly handle the case of a NULL vm_ops pointer
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 19 Oct 2012 20:37:57 +0000 (13:37 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 19 Oct 2012 20:37:57 +0000 (13:37 -0700)
In commit 0b173bc4daa8 ("mm: kill vma flag VM_CAN_NONLINEAR") we
replaced the VM_CAN_NONLINEAR test with checking whether the mapping has
a '->remap_pages()' vm operation, but there is no guarantee that there
it even has a vm_ops pointer at all.

Add the appropriate test for NULL vm_ops.

Reported-by: Sasha Levin <levinsasha928@gmail.com>
Cc: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/fremap.c

index 3899a86851ceb6bf021e51c014fef16e0893a7f0..a0aaf0e56800394be8b9ae0d0da47712b6e0bb53 100644 (file)
@@ -169,7 +169,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
        if (vma->vm_private_data && !(vma->vm_flags & VM_NONLINEAR))
                goto out;
 
        if (vma->vm_private_data && !(vma->vm_flags & VM_NONLINEAR))
                goto out;
 
-       if (!vma->vm_ops->remap_pages)
+       if (!vma->vm_ops || !vma->vm_ops->remap_pages)
                goto out;
 
        if (start < vma->vm_start || start + size > vma->vm_end)
                goto out;
 
        if (start < vma->vm_start || start + size > vma->vm_end)