Skip to content

Commit

Permalink
mmap: check ->vm_ops before dereferencing
Browse files Browse the repository at this point in the history
Check whether the VMA has a vm_ops before calling close, just
like we check vm_ops before calling open a few dozen lines
higher up in the function.

Signed-off-by: Rik van Riel <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Rik van Riel authored and torvalds committed Apr 27, 2010
1 parent a231a1f commit 5892753
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,8 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
return 0;

/* Clean everything up if vma_adjust failed. */
new->vm_ops->close(new);
if (new->vm_ops && new->vm_ops->close)
new->vm_ops->close(new);
if (new->vm_file) {
if (vma->vm_flags & VM_EXECUTABLE)
removed_exe_file_vma(mm);
Expand Down

0 comments on commit 5892753

Please sign in to comment.