re: drm/radeon: fix AGP userptr handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Christian König,

This is a semi-automatic email about new static checker warnings.

The patch 3840a656f61f: "drm/radeon: fix AGP userptr handling" from 
Sep 17, 2014, leads to the following Smatch complaint:

drivers/gpu/drm/radeon/radeon_ttm.c:708 radeon_ttm_tt_populate()
	 error: we previously assumed 'gtt' could be null (see line 696)

drivers/gpu/drm/radeon/radeon_ttm.c
   695	
   696		if (gtt && gtt->userptr) {
                    ^^^
New check.

   697			ttm->sg = kcalloc(1, sizeof(struct sg_table), GFP_KERNEL);
   698			if (!ttm->sg)
   699				return -ENOMEM;
   700	
   701			ttm->page_flags |= TTM_PAGE_FLAG_SG;
   702			ttm->state = tt_unbound;
   703			return 0;
   704		}
   705	
   706		if (slave && ttm->sg) {
   707			drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
   708							 gtt->ttm.dma_address, ttm->num_pages);
                                                         ^^^^^^^^
Old unchecked dereference.

   709			ttm->state = tt_unbound;
   710			return 0;


drivers/gpu/drm/radeon/radeon_ttm.c
   754	
   755		if (gtt && gtt->userptr) {
                    ^^^
   756			kfree(ttm->sg);
   757			ttm->page_flags &= ~TTM_PAGE_FLAG_SG;
   758			return;
   759		}
   760	
   761		if (slave)
   762			return;
   763	
   764		rdev = radeon_get_rdev(ttm->bdev);
   765	#if __OS_HAS_AGP
   766		if (rdev->flags & RADEON_IS_AGP) {
   767			ttm_agp_tt_unpopulate(ttm);
   768			return;
   769		}
   770	#endif
   771	
   772	#ifdef CONFIG_SWIOTLB
   773		if (swiotlb_nr_tbl()) {
   774			ttm_dma_unpopulate(&gtt->ttm, rdev->dev);
   775			return;
   776		}
   777	#endif
   778	
   779		for (i = 0; i < ttm->num_pages; i++) {
   780			if (gtt->ttm.dma_address[i]) {
                            ^^^^^^^^
   781				pci_unmap_page(rdev->pdev, gtt->ttm.dma_address[i],
   782					       PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);

regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux