dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: dave.jiang@intel.com
Cc: dmaengine@vger.kernel.org
Subject: [bug report] dmaengine: break out channel registration
Date: Fri, 31 Jan 2020 08:00:36 +0300	[thread overview]
Message-ID: <20200131050036.fqb4ke6phimki4x7@kili.mountain> (raw)

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

                 reply	other threads:[~2020-01-31  5:00 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=20200131050036.fqb4ke6phimki4x7@kili.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).