* re: drm/radeon: fix AGP userptr handling
@ 2014-09-24 15:27 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2014-09-24 15:27 UTC (permalink / raw)
To: christian.koenig; +Cc: dri-devel
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(>t->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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-09-24 15:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-24 15:27 drm/radeon: fix AGP userptr handling Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.