From: Matthew Wilcox <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Wan Jiabing <wanjiabing@vivo.com>,
Vlastimil Babka <vbabka@suse.cz>,
David Howells <dhowells@redhat.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Julia Lawall <Julia.Lawall@inria.fr>
Subject: Re: [PATCH] mm/filemap: Fix NULL pointer dereference in pagecache_get_page
Date: Tue, 26 Apr 2022 22:17:37 +0100 [thread overview]
Message-ID: <YmhhcQuXO7ZKjolH@casper.infradead.org> (raw)
In-Reply-To: <20220426140641.cc78a429e1fa32ed0e15520b@linux-foundation.org>
On Tue, Apr 26, 2022 at 02:06:41PM -0700, Andrew Morton wrote:
> On Tue, 26 Apr 2022 13:08:08 +0100 Matthew Wilcox <willy@infradead.org> wrote:
>
> > On Tue, Apr 26, 2022 at 04:25:48PM +0800, Wan Jiabing wrote:
> > > Fix following coccicheck error:
> > > mm/folio-compat.c:128:17-21: ERROR: folio is NULL but dereferenced.
> > > folio = __filemap_get_folio(mapping, index, fgp_flags, gfp);
> > > - if ((fgp_flags & FGP_HEAD) || !folio || xa_is_value(folio))
> > > + if (!folio)
> > > + return NULL;
> > > + if ((fgp_flags & FGP_HEAD) || xa_is_value(folio))
> > > return &folio->page;
> >
> > That doesn't dereference the folio. Coccicheck is wrong.
>
> Doing
>
> return &(0->page);
>
> is a rather obscure way of doing `return NULL;'.
>
> I agree the patch doesn't fix anything, but it results in saner-looking code?
I suppose that's in the eye of the beholder? The original code makes
more sense to me. Besides, it's in the folio-compat file; nobody
should be looking at that except to figure out "What function should I
be transitioning to?"
prev parent reply other threads:[~2022-04-26 21:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-26 8:25 [PATCH] mm/filemap: Fix NULL pointer dereference in pagecache_get_page Wan Jiabing
2022-04-26 12:08 ` Matthew Wilcox
2022-04-26 21:06 ` Andrew Morton
2022-04-26 21:17 ` Matthew Wilcox [this message]
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=YmhhcQuXO7ZKjolH@casper.infradead.org \
--to=willy@infradead.org \
--cc=Julia.Lawall@inria.fr \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vbabka@suse.cz \
--cc=wanjiabing@vivo.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).