mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Ethan Tidmore <ethantidmore06@gmail.com>
Cc: Andreas Gruenbacher <agruenba@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	gfs2@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gfs2: Fix error pointer dereference
Date: Wed, 18 Feb 2026 21:14:43 +0000	[thread overview]
Message-ID: <aZYrw29iK1ak5Npw@casper.infradead.org> (raw)
In-Reply-To: <20260218200645.15713-1-ethantidmore06@gmail.com>

On Wed, Feb 18, 2026 at 02:06:45PM -0600, Ethan Tidmore wrote:
> The function __filemap_get_folio() can return an error pointer and is
> not checked for one. Add check for error pointer.

Can you explain how __filemap_get_folio() would fail, given the
presence of __GFP_NOFAIL in the GFP flags?

> Detected by Smatch:
> fs/gfs2/meta_io.c:147 gfs2_getbuf() error:
> 'folio' dereferencing possible ERR_PTR()
> 
> Fixes: 0eb751791df86 ("gfs2: convert gfs2_getbuf() to folios")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>  fs/gfs2/meta_io.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
> index 3c8e4553102d..9c0ba4c3cb29 100644
> --- a/fs/gfs2/meta_io.c
> +++ b/fs/gfs2/meta_io.c
> @@ -144,6 +144,8 @@ struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno, int create)
>  		folio = __filemap_get_folio(mapping, index,
>  				FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
>  				mapping_gfp_mask(mapping) | __GFP_NOFAIL);
> +		if (IS_ERR(folio))
> +			return NULL;
>  		bh = folio_buffers(folio);
>  		if (!bh)
>  			bh = create_empty_buffers(folio,
> -- 
> 2.53.0
> 

  reply	other threads:[~2026-02-18 21:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-18 20:06 Ethan Tidmore
2026-02-18 21:14 ` Matthew Wilcox [this message]
2026-02-18 21:53   ` Ethan Tidmore

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=aZYrw29iK1ak5Npw@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=agruenba@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ethantidmore06@gmail.com \
    --cc=gfs2@lists.linux.dev \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®