drm/ttm: Refuse to fault (prime-) imported pages

Dan Carpenter dan.carpenter at oracle.com
Mon May 9 19:39:16 UTC 2016


Hello Thomas Hellstrom,

The patch 667a50db0477: "drm/ttm: Refuse to fault (prime-) imported
pages" from Jan 3, 2014, leads to the following static checker
warning:

	drivers/gpu/drm/ttm/ttm_bo_vm.c:205 ttm_bo_vm_fault()
	error: we previously assumed 'ttm' could be null (see line 200)

drivers/gpu/drm/ttm/ttm_bo_vm.c
   133          /*
   134           * Refuse to fault imported pages. This should be handled
   135           * (if at all) by redirecting mmap to the exporter.
   136           */
   137          if (bo->ttm && (bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) {
                    ^^^^^^^
New check for NULL.  Is this really needed?

   138                  retval = VM_FAULT_SIGBUS;
   139                  goto out_unlock;
   140          }

[ snip ]

   188          /*
   189           * Make a local vma copy to modify the page_prot member
   190           * and vm_flags if necessary. The vma parameter is protected
   191           * by mmap_sem in write mode.
   192           */
   193          cvma = *vma;
   194          cvma.vm_page_prot = vm_get_page_prot(cvma.vm_flags);
   195  
   196          if (bo->mem.bus.is_iomem) {
   197                  cvma.vm_page_prot = ttm_io_prot(bo->mem.placement,
   198                                                  cvma.vm_page_prot);
   199          } else {
   200                  ttm = bo->ttm;
                        ^^^^^^^^^^^^^
   201                  cvma.vm_page_prot = ttm_io_prot(bo->mem.placement,
   202                                                  cvma.vm_page_prot);
   203  
   204                  /* Allocate all page at once, most common usage */
   205                  if (ttm->bdev->driver->ttm_tt_populate(ttm)) {
                            ^^^^^^^^^
Old unchecked dereference.

   206                          retval = VM_FAULT_OOM;
   207                          goto out_io_unlock;
   208                  }
   209          }
   210  


regards,
dan carpenter


More information about the dri-devel mailing list