All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: christian.koenig@amd.com
Cc: dri-devel@lists.freedesktop.org
Subject: re: drm/radeon: fix AGP userptr handling
Date: Wed, 24 Sep 2014 18:27:04 +0300	[thread overview]
Message-ID: <20140924151425.GA20296@mwanda> (raw)

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

                 reply	other threads:[~2014-09-24 15:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140924151425.GA20296@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.