All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <gaoxiang25@huawei.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: xiang@kernel.org, linux-erofs@lists.ozlabs.org
Subject: Re: [bug report] staging: erofs: tidy up decompression frontend
Date: Tue, 27 Aug 2019 18:05:23 +0800	[thread overview]
Message-ID: <20190827100523.GA236561@architecture4> (raw)
In-Reply-To: <20190827095347.GN3964@kadam>

On Tue, Aug 27, 2019 at 12:53:47PM +0300, Dan Carpenter wrote:
> On Tue, Aug 27, 2019 at 05:36:29PM +0800, Gao Xiang wrote:
> > Hi Dan,
> > 
> > Thanks for your report.
> > 
> > On Tue, Aug 27, 2019 at 12:03:55PM +0300, Dan Carpenter wrote:
> > > Hello Gao Xiang,
> > > 
> > > This is a semi-automatic email about new static checker warnings.
> > > 
> > > The patch 97e86a858bc3: "staging: erofs: tidy up decompression
> > > frontend" from Jul 31, 2019, leads to the following Smatch complaint:
> > > 
> > >     fs/erofs/zdata.c:670 z_erofs_do_read_page()
> > >     error: we previously assumed 'clt->cl' could be null (see line 596)
> > > 
> > > fs/erofs/zdata.c
> > >    595			/* didn't get a valid collection previously (very rare) */
> > >    596			if (!clt->cl)
> > >                             ^^^^^^^^
> > > New NULL check.
> > > 
> > >    597				goto restart_now;
> > >    598			goto hitted;
> > >    599		}
> > >    600	
> > >    601		/* go ahead the next map_blocks */
> > >    602		debugln("%s: [out-of-range] pos %llu", __func__, offset + cur);
> > >    603	
> > >    604		if (z_erofs_collector_end(clt))
> > >    605			fe->backmost = false;
> > >    606	
> > >    607		map->m_la = offset + cur;
> > >    608		map->m_llen = 0;
> > >    609		err = z_erofs_map_blocks_iter(inode, map, 0);
> > >    610		if (unlikely(err))
> > >    611			goto err_out;
> > >    612	
> > >    613	restart_now:
> > >    614		if (unlikely(!(map->m_flags & EROFS_MAP_MAPPED)))
> > >    615			goto hitted;
> > >    616	
> > >    617		err = z_erofs_collector_begin(clt, inode, map);
> > 
> > At a glance, clt->cl will be all initialized in all successful paths
> > in z_erofs_collector_begin, or it all fall back into err_out...
> > I have no idea what is wrong here...
> > 
> > Some detailed path from Smatch for NIL dereferences?
> > 
> 
> Ah.  Sorry for that.  It's a false positive.  I will investigate and
> fix Smatch.

Yeah.. I was little confused, since this patch mostly renames many names...
and the main logic is unchanged for months... and for this case there are 2 paths...

 1) hit line 614 --> goto hitted --> hit line 633 --> goto next_part; (will skip line 670);
 2) hit line 617 --> go into z_erofs_collector_begin -->
    all successful paths will assign clt->cl, so clt->cl != NULL...

Though z_erofs_do_read_page is currently somewhat complicated (mostly due to some
historical fixes in order to backport friendly), I will simplify this function
in the later version (..and with care in case of introducing new bugs) :-)

Thanks,
Gao Xiang

> 
> regards,
> dan carpenter
> 

  reply	other threads:[~2019-08-27 10:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27  9:03 [bug report] staging: erofs: tidy up decompression frontend Dan Carpenter
2019-08-27  9:36 ` Gao Xiang
2019-08-27  9:53   ` Dan Carpenter
2019-08-27 10:05     ` Gao Xiang [this message]
2019-08-27 10:42     ` Dan Carpenter
2019-08-27 10:46       ` Gao Xiang
  -- strict thread matches above, loose matches on Subject: below --
2019-11-14 19:10 Dan Carpenter
2019-11-14 19:10 ` Dan Carpenter
2019-11-14 22:00 ` Matthew Wilcox
2019-11-14 22:00   ` Matthew Wilcox
2019-11-15  0:45   ` Gao Xiang via Linux-erofs
2019-11-15  0:45     ` Gao Xiang

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=20190827100523.GA236561@architecture4 \
    --to=gaoxiang25@huawei.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=xiang@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 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.