]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gfs2: fix double destroy_workqueue error
authorJulian Sun <sunjunchao2870@gmail.com>
Tue, 20 Aug 2024 03:31:48 +0000 (11:31 +0800)
committerAndreas Gruenbacher <agruenba@redhat.com>
Tue, 20 Aug 2024 14:27:22 +0000 (16:27 +0200)
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: syzbot+d34c2a269ed512c531b0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d34c2a269ed512c531b0
Fixes: 30e388d57367 ("gfs2: Switch to a per-filesystem glock workqueue")
Cc: stable@vger.kernel.org
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/glock.c
fs/gfs2/ops_fstype.c

index 4a026703a28d865ad38be8dbbafb6a1a84140844..269c3bc7fced7133c3e893bc8f2c471946c0ce35 100644 (file)
@@ -2251,6 +2251,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp)
        gfs2_free_dead_glocks(sdp);
        glock_hash_walk(dump_glock_func, sdp);
        destroy_workqueue(sdp->sd_glock_wq);
+       sdp->sd_glock_wq = NULL;
 }
 
 static const char *state2str(unsigned state)
index ff1f3e3dc65c9db08728fee9ef707a3b911d1302..e83d293c361423493ca94059ad64e089859746af 100644 (file)
@@ -1307,7 +1307,8 @@ fail_debug:
 fail_delete_wq:
        destroy_workqueue(sdp->sd_delete_wq);
 fail_glock_wq:
-       destroy_workqueue(sdp->sd_glock_wq);
+       if (sdp->sd_glock_wq)
+               destroy_workqueue(sdp->sd_glock_wq);
 fail_free:
        free_sbd(sdp);
        sb->s_fs_info = NULL;