mmap: check ->vm_ops before dereferencing

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]>
This commit is contained in:
Rik van Riel 2010-04-26 12:33:03 -04:00 • committed by Linus Torvalds
commit 5892753383

View file

@ -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);