dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Green Wan <green.wan@sifive.com>
Cc: dmaengine@vger.kernel.org
Subject: Re: [bug report] dmaengine: sf-pdma: add platform DMA support for HiFive Unleashed A00
Date: Mon, 18 Nov 2019 10:36:37 +0300	[thread overview]
Message-ID: <20191118063704.GC1776@kadam> (raw)
In-Reply-To: <CAJivOr7ZaZWzw-5QnOkakmBhN3TidzoM_WwDVpPAsaGp5tMw-Q@mail.gmail.com>

On Mon, Nov 18, 2019 at 12:25:14PM +0800, Green Wan wrote:
> Hi Dan,
> 
> Thanks for reaching out. I do have the same question before. If I
> remember it correctly, the 'chan' is returned by to_sf_pdma_chan()
> which contains 'dchan'. 'chan' s unlikely to be NULL since it's
> container.

to_sf_pdma_chan() is really a no-op when you read it carefully.  "chan"
and "dchan" are equivalent.  Smatch parses it correctly.

You are obviously correct that people should check the original "dchan"
instead of the returned "chan", but I feel like some people are clever
enough to know when container_of() is a no-op and deliberately check the
returned value...  These are sorts of people you don't want to get into
a debate with because they're an ultra annoying blend of clever and
dumb.

My other comment here is that Smatch doesn't warn about inconsistent
NULL checking when the pointer is provably non-NULL.  In this case, the
only caller that Smatch doesn't parse correctly is ioat_dma_self_test().
For all the other callers it knows that "dchan" is non-NULL.  In
ioat_dma_self_test() the code looks like:

   330          /* Start copy, using first DMA channel */
   331          dma_chan = container_of(dma->channels.next, struct dma_chan,
   332                                  device_node);

Smatch says that both "dma->channels.next" and "dma_chan" are complete
unknowns.

I could probably safely mark dma_chan as a valid pointer in this
instance which would make the warning disappear...  Maybe I will add a
check to see if "dma->channels.next" can be controlled by the user.

regards,
dan carpenter


  reply	other threads:[~2019-11-18  7:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-16  8:23 [bug report] dmaengine: sf-pdma: add platform DMA support for HiFive Unleashed A00 Dan Carpenter
2019-11-18  4:25 ` Green Wan
2019-11-18  7:36   ` Dan Carpenter [this message]
2019-11-18  8:41     ` Green Wan

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=20191118063704.GC1776@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=green.wan@sifive.com \
    /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).