mmap: check ->vm_ops before dereferencing

Previous thread: drm/radeon/kms/evergreen: No EnableYUV table by Linux Kernel Mailing List on Tuesday, April 27, 2010 - 9:59 am. (1 message)

Next thread: drm/radeon: 9800 SE has only one quadpipe by Linux Kernel Mailing List on Tuesday, April 27, 2010 - 9:59 am. (1 message)
From: Linux Kernel Mailing List
Date: Tuesday, April 27, 2010 - 9:59 am

Gitweb:     http://git.kernel.org/linus/5892753383090a3eddf0e1b043c95e3b2c7feda5
Commit:     5892753383090a3eddf0e1b043c95e3b2c7feda5
Parent:     a231a1f2714ce3b28445ac512a556d6c95517dab
Author:     Rik van Riel <riel@redhat.com>
AuthorDate: Mon Apr 26 12:33:03 2010 -0400
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Tue Apr 27 08:26:51 2010 -0700

    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 <riel@redhat.com>
    Reported-by: Dan Carpenter <error27@gmail.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 mm/mmap.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index f90ea92..456ec6f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -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);
--

Previous thread: drm/radeon/kms/evergreen: No EnableYUV table by Linux Kernel Mailing List on Tuesday, April 27, 2010 - 9:59 am. (1 message)

Next thread: drm/radeon: 9800 SE has only one quadpipe by Linux Kernel Mailing List on Tuesday, April 27, 2010 - 9:59 am. (1 message)