All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: kbuild-all@lists.01.org
Subject: Re: [rdma-rdma:wip/jgg-for-next 198/203] drivers/infiniband/ulp/rtrs/rtrs-srv.c:1805 rtrs_rdma_connect() warn: passing zero to 'PTR_ERR'
Date: Tue, 16 Feb 2021 14:58:15 -0400	[thread overview]
Message-ID: <20210216185815.GF4247@nvidia.com> (raw)
In-Reply-To: <20210215135757.GB2222@kadam>

[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]

On Mon, Feb 15, 2021 at 04:57:57PM +0300, Dan Carpenter wrote:
> > > d715ff8acbd587 Guoqing Jiang  2020-10-23  1800          /*
> > > d715ff8acbd587 Guoqing Jiang  2020-10-23  1801           * "refcount == 0" happens if a previous thread calls get_or_create_srv
> > > d715ff8acbd587 Guoqing Jiang  2020-10-23  1802           * allocate srv, but chunks of srv are not allocated yet.
> > > d715ff8acbd587 Guoqing Jiang  2020-10-23  1803           */
> > > f0751419d3a15f Md Haris Iqbal 2021-02-12  1804          if (IS_ERR(srv) || refcount_read(&srv->refcount) == 0) {
> > > f0751419d3a15f Md Haris Iqbal 2021-02-12 @1805                  err = PTR_ERR(srv);
> > >
> > > It's not 100% clear to me that an error code is required when
> > > refcount_read() is zero.  Maybe "err = 0;" is okay in that situation?
> > I don't see how srv can be zero
> 
> The cross function database was probably out of date.

Regardless of if it is up to date or not, this sequence:

    if (refcount_read(&srv->refcount) == 0)
         err = PTR_ERR(srv);

Is completely bogus

eg prove srv is a valid pointer by de-refing and then passing a valid
pointer to PTR_ERR

Jason

  reply	other threads:[~2021-02-16 18:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAMGffEm3ZbPxXzERHLogitw9oz_UK88KE+SZSCy4x1PdvquDZw@mail.gmail.com>
2021-02-15 13:57 ` [rdma-rdma:wip/jgg-for-next 198/203] drivers/infiniband/ulp/rtrs/rtrs-srv.c:1805 rtrs_rdma_connect() warn: passing zero to 'PTR_ERR' Dan Carpenter
2021-02-15 13:57   ` Dan Carpenter
2021-02-16 18:58   ` Jason Gunthorpe [this message]
     [not found] <CAMGffEmbY1FMOHQsKeUK-f=JT6QFGE44Mmu=OFttEJVanbeXvg@mail.gmail.com>
2021-02-15 14:16 ` Dan Carpenter
2021-02-15 14:16   ` Dan Carpenter
2021-02-15 12:44 Dan Carpenter
2021-02-15 12:44 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2021-02-12 21:28 kernel test robot

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=20210216185815.GF4247@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=kbuild-all@lists.01.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.