[bug report] dmaengine: break out channel registration

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

 



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



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux