Skip to content

Commit 6cb9df8

Browse files
jc2870Andreas Gruenbacher
authored andcommitted
gfs2: fix double destroy_workqueue error
When gfs2_fill_super() fails, destroy_workqueue() is called within gfs2_gl_hash_clear(), and the subsequent code path calls destroy_workqueue() on the same work queue again. This issue can be fixed by setting the work queue pointer to NULL after the first destroy_workqueue() call and checking for a NULL pointer before attempting to destroy the work queue again. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=d34c2a269ed512c531b0 Fixes: 30e388d ("gfs2: Switch to a per-filesystem glock workqueue") Cc: [email protected] Signed-off-by: Julian Sun <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 4117efd commit 6cb9df8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

fs/gfs2/glock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp)
22512251
gfs2_free_dead_glocks(sdp);
22522252
glock_hash_walk(dump_glock_func, sdp);
22532253
destroy_workqueue(sdp->sd_glock_wq);
2254+
sdp->sd_glock_wq = NULL;
22542255
}
22552256

22562257
static const char *state2str(unsigned state)

fs/gfs2/ops_fstype.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,8 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
13071307
fail_delete_wq:
13081308
destroy_workqueue(sdp->sd_delete_wq);
13091309
fail_glock_wq:
1310-
destroy_workqueue(sdp->sd_glock_wq);
1310+
if (sdp->sd_glock_wq)
1311+
destroy_workqueue(sdp->sd_glock_wq);
13111312
fail_free:
13121313
free_sbd(sdp);
13131314
sb->s_fs_info = NULL;

0 commit comments

Comments
 (0)