dmaengine Archive on lore.kernel.org
 help / color / Atom feed
* [bug report] dmaengine: break out channel registration
@ 2020-01-31  5:00 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2020-01-31  5:00 UTC (permalink / raw)
  To: dave.jiang; +Cc: dmaengine

Hello Dave Jiang,

The patch d2fb0a043838: "dmaengine: break out channel registration"
from Jan 21, 2020, leads to the following static checker warning:

	drivers/dma/dmaengine.c:965 __dma_async_device_channel_register()
	error: potential NULL dereference 'tchan'.

drivers/dma/dmaengine.c
   954  static int __dma_async_device_channel_register(struct dma_device *device,
   955                                                 struct dma_chan *chan,
   956                                                 int chan_id)
   957  {
   958          int rc = 0;
   959          int chancnt = device->chancnt;
   960          atomic_t *idr_ref;
   961          struct dma_chan *tchan;
   962  
   963          tchan = list_first_entry_or_null(&device->channels,
                                        ^^^^^^^^
The "or_null" suggests that "tchan" can be NULL

   964                                           struct dma_chan, device_node);
   965          if (tchan->dev) {
                    ^^^^^^^^^^
so this should be "if (tchan && tchan->dev)"?

   966                  idr_ref = tchan->dev->idr_ref;
   967          } else {
   968                  idr_ref = kmalloc(sizeof(*idr_ref), GFP_KERNEL);
   969                  if (!idr_ref)
   970                          return -ENOMEM;
   971                  atomic_set(idr_ref, 0);
   972          }
   973  
   974          chan->local = alloc_percpu(typeof(*chan->local));
   975          if (!chan->local)
   976                  goto err_out;

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-31  5:00 [bug report] dmaengine: break out channel registration Dan Carpenter

dmaengine Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dmaengine/0 dmaengine/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dmaengine dmaengine/ https://lore.kernel.org/dmaengine \
		dmaengine@vger.kernel.org
	public-inbox-index dmaengine

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.dmaengine


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git