[PATCH 4/5] gfs2: handle NULL return value in callers of gfs2_meta_ra()

From: Mauricio Faria de Oliveira

Date: Tue Sep 08 2026 - 17:23:59 EST


Now that gfs2_meta_ra() can return NULL (instead of hit a kernel oops),
update its callers to handle it (and not hit another kernel oops).

If gfs2_meta_ra() returns NULL:

- gfs2_quota_init()

It currently checks for NULL and returns -EIO.

- gfs2_dir_read_data()

Return -EIO. Fail as currently done in other cases.

- gfs2_replay_read_block()

Return -EIO. It can currently return errors.

Signed-off-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxx>
---
fs/gfs2/dir.c | 4 ++++
fs/gfs2/recovery.c | 2 ++
2 files changed, 6 insertions(+)

diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index d1dc1e94b6c432d2ede504b04cb71959285a945d..d9e0b6b19567c8aa8518b9245e9bdfd3ccf7c1a7 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -302,6 +302,10 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, __be64 *buf,
goto fail;
BUG_ON(extlen < 1);
bh = gfs2_meta_ra(ip->i_gl, dblock, extlen);
+ if (!bh) {
+ error = -EIO;
+ goto fail;
+ }
} else {
error = gfs2_meta_read(ip->i_gl, dblock, DIO_WAIT, 0, &bh);
if (error)
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 616c46aa3434ae6ad84d10d678ca3f6dbe9492f5..e39754e08f44d67b460a47744f4276cd168e356c 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -48,6 +48,8 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
}

*bh = gfs2_meta_ra(gl, dblock, extlen);
+ if (!*bh)
+ error = -EIO;

return error;
}

--
2.47.3