[lvc-project] [PATCH] gfs2: Remove unnecessary sd_jdesc NULL check
Nikolai Kuznetsov
niku.csmsu at yandex.ru
Tue Apr 14 19:17:49 MSK 2026
Commit 35264909e9d1 ("gfs2: Fix NULL pointer dereference in
gfs2_log_flush") added an explicit NULL check for sd_jdesc
to avoid a race with unmount.
Note that the explicit NULL check alone was insufficient, as other
functions e.g. log_distance() still dereference sd_jdesc.
However, gfs2_log_flush() checks for SDF_JOURNAL_LIVE bit and bails
out if it's not set. During unmount this bit is cleared in final
shutdown flush which is called in gfs2_make_fs_ro().
Filesystem becomes RO firstly and only then sd_jdesc is assigned
NULL in gfs2_jindex_free(), so the race is not possible. The
explicit check is redundant, remove it.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 35264909e9d1 ("gfs2: Fix NULL pointer dereference in gfs2_log_flush")
Fixes: 74b4dbb94606 ("gfs2: prevent NULL pointer dereference during unmount")
Signed-off-by: Nikolai Kuznetsov <niku.csmsu at yandex.ru>
---
fs/gfs2/log.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 78bba8cc10b8..0b91f3e0928a 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -467,7 +467,7 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)
{
atomic_add(blks, &sdp->sd_log_blks_free);
trace_gfs2_log_blocks(sdp, blks);
- gfs2_assert_withdraw(sdp, !sdp->sd_jdesc ||
+ gfs2_assert_withdraw(sdp,
atomic_read(&sdp->sd_log_blks_free) <=
sdp->sd_jdesc->jd_blocks);
if (atomic_read(&sdp->sd_log_blks_needed))
@@ -1137,8 +1137,9 @@ static void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
lops_before_commit(sdp, tr);
if (gfs2_withdrawn(sdp))
goto out_withdraw;
- if (sdp->sd_jdesc)
- gfs2_log_submit_write(&sdp->sd_jdesc->jd_log_bio);
+
+ gfs2_log_submit_write(&sdp->sd_jdesc->jd_log_bio);
+
if (gfs2_withdrawn(sdp))
goto out_withdraw;
--
2.43.0
More information about the lvc-project
mailing list