[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aPiJkhNJ4dgOlMIj@stanley.mountain>
Date: Wed, 22 Oct 2025 10:36:50 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Trond Myklebust <trondmy@...nel.org>
Cc: liubaolin <liubaolin12138@....com>, anna@...nel.org,
linux-nfs@...r.kernel.org, linux-kernel@...r.kernel.org,
Baolin Liu <liubaolin@...inos.cn>
Subject: Re: [PATCH v1] NFS: Fix possible NULL pointer dereference in
nfs_inode_remove_request()
On Wed, Oct 22, 2025 at 10:34:56AM +0300, Dan Carpenter wrote:
> On Tue, Oct 21, 2025 at 11:15:21PM -0400, Trond Myklebust wrote:
> > On Wed, 2025-10-22 at 10:44 +0800, liubaolin wrote:
> > > > Sorry, I didn’t actually see any case where req->wb_head == NULL.
> > > > I found this through a smatch warning that pointed out a potential
> > > > null pointer dereference.
> > > > Instead of removing the NULL folio check, I prefer to keep it to
> > > > prevent this potential issue. Checking pointer validity before use
> > > > is a good practice.
> > > > From a maintenance perspective, we can’t rule out the possibility
> > > > that future changes might introduce a req->wb_head == NULL case, so
> > > > I suggest keeping the NULL folio check.
> > >
> >
> > I think you need to look at how smatch works in these situations. It is
> > not looking at the call chain, but is rather looking at how the
> > function is structured.
> > Specifically, as I understand it, smatch looks at whether a test for a
> > NULL pointer exists, and whether it is placed before or after the
> > pointer is dereferenced. So it has nothing to say about whether the
> > check is needed; all it says is that *if* the check is needed, then it
> > should be placed differently.
> > Dan Carpenter, please correct me if my information above is outdated...
>
> Yes. That's the gist of it.
>
> However Smatch can tell that the check is not needed then the warning
> won't be printed.
However IF Smatch...
Gar.
regards,
dan carpenter
Powered by blists - more mailing lists