Skip to content

Commit

Permalink
remap_file_pages: correctly handle the case of a NULL vm_ops pointer
Browse files Browse the repository at this point in the history
In commit 0b173bc ("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 <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
torvalds committed Oct 19, 2012
1 parent 17dbe27 commit deb521c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/fremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_ops->remap_pages)
if (!vma->vm_ops || !vma->vm_ops->remap_pages)
goto out;

if (start < vma->vm_start || start + size > vma->vm_end)
Expand Down

0 comments on commit deb521c

Please sign in to comment.