gfs2: fix possible reference leak in gfs2_check_blk_type
authorZhang Qilong <zhangqilong3@huawei.com>
Sun, 8 Nov 2020 09:27:41 +0000 (17:27 +0800)
committerAndreas Gruenbacher <agruenba@redhat.com>
Thu, 12 Nov 2020 12:09:07 +0000 (13:09 +0100)
In the fail path of gfs2_check_blk_type, forgetting to call
gfs2_glock_dq_uninit will result in rgd_gh reference leak.

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/rgrp.c

index 92d799a..f7addc6 100644 (file)
@@ -2529,13 +2529,13 @@ int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr, unsigned int type)
 
        rbm.rgd = rgd;
        error = gfs2_rbm_from_block(&rbm, no_addr);
-       if (WARN_ON_ONCE(error))
-               goto fail;
-
-       if (gfs2_testbit(&rbm, false) != type)
-               error = -ESTALE;
+       if (!WARN_ON_ONCE(error)) {
+               if (gfs2_testbit(&rbm, false) != type)
+                       error = -ESTALE;
+       }
 
        gfs2_glock_dq_uninit(&rgd_gh);
+
 fail:
        return error;
 }