From: Michel Dänzer <daen...@vmware.com>

Make sure bo->vm_node is valid, to prevent crashes in the fault handler, and
adjust vma->vm_pgoff according to it, so userspace attempts to access /dev/fb*
mappings don't always result in SIGBUS.

Signed-off-by: Michel Dänzer <daen...@vmware.com>
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 27b146c..57d0c94 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -282,7 +282,13 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma, struct 
ttm_buffer_object *bo)
        if (vma->vm_pgoff != 0)
                return -EACCES;
 
+       if (!bo->vm_node) {
+               printk(KERN_ERR TTM_PFX "bo->vm_node == NULL\n");
+               return -EACCES;
+       }
+
        vma->vm_ops = &ttm_bo_vm_ops;
+       vma->vm_pgoff = bo->vm_node->start;
        vma->vm_private_data = ttm_bo_reference(bo);
        vma->vm_flags |= VM_RESERVED | VM_IO | VM_MIXEDMAP | VM_DONTEXPAND;
        return 0;
-- 
1.6.3.3


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to