[PATCH] gfs2: Fix potential recovery bitmap leak on mount failure

From: Guangshuo Li

Date: Tue Nov 10 2026 - 09:34:30 EST


set_recover_size() can allocate the LVB bitmap before failing to allocate
the recovery arrays. Use the recovery cleanup path on this failure so
the bitmap is released before the superblock is freed.

This issue was found by our static analysis tool under development.

Fixes: 57c7310b8eb9 ("GFS2: use kmalloc for lvb bitmap")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
fs/gfs2/lock_dlm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
index 47eec0c13025..f3d2c6ad614f 100644
--- a/fs/gfs2/lock_dlm.c
+++ b/fs/gfs2/lock_dlm.c
@@ -1315,7 +1315,7 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *table)

error = set_recover_size(sdp, NULL, 0);
if (error)
- goto fail;
+ goto fail_free;

/*
* prepare dlm_new_lockspace args
@@ -1384,7 +1384,6 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *table)
dlm_release_lockspace(ls->ls_dlm, DLM_RELEASE_NORMAL);
fail_free:
free_recover_size(ls);
-fail:
return error;
}


base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4