]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: Fix rmaps_verify_btree() error path origin/for-next_2022-12-13
authorCarlos Maiolino <cmaiolino@redhat.com>
Thu, 1 Dec 2022 09:34:08 +0000 (10:34 +0100)
committerCarlos Maiolino <cem@kernel.org>
Fri, 9 Dec 2022 09:24:04 +0000 (10:24 +0100)
Add proper exit error paths to avoid checking all pointers at the current path

Fixes-coverity-id: 1512654

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
repair/rmap.c

index 9ec5e9e13eb305ee03444b5c8467026083394a15..52106fd42f1346a774f901cbeca835bed4029a9a 100644 (file)
@@ -1004,7 +1004,7 @@ rmaps_verify_btree(
        if (error) {
                do_warn(_("Could not read AGF %u to check rmap btree.\n"),
                                agno);
-               goto err;
+               goto err_pag;
        }
 
        /* Leave the per-ag data "uninitialized" since we rewrite it later */
@@ -1013,7 +1013,7 @@ rmaps_verify_btree(
        bt_cur = libxfs_rmapbt_init_cursor(mp, NULL, agbp, pag);
        if (!bt_cur) {
                do_warn(_("Not enough memory to check reverse mappings.\n"));
-               goto err;
+               goto err_agf;
        }
 
        rm_rec = pop_slab_cursor(rm_cur);
@@ -1023,7 +1023,7 @@ rmaps_verify_btree(
                        do_warn(
 _("Could not read reverse-mapping record for (%u/%u).\n"),
                                        agno, rm_rec->rm_startblock);
-                       goto err;
+                       goto err_cur;
                }
 
                /*
@@ -1039,7 +1039,7 @@ _("Could not read reverse-mapping record for (%u/%u).\n"),
                                do_warn(
 _("Could not read reverse-mapping record for (%u/%u).\n"),
                                                agno, rm_rec->rm_startblock);
-                               goto err;
+                               goto err_cur;
                        }
                }
                if (!have) {
@@ -1090,13 +1090,12 @@ next_loop:
                rm_rec = pop_slab_cursor(rm_cur);
        }
 
-err:
-       if (bt_cur)
-               libxfs_btree_del_cursor(bt_cur, XFS_BTREE_NOERROR);
-       if (pag)
-               libxfs_perag_put(pag);
-       if (agbp)
-               libxfs_buf_relse(agbp);
+err_cur:
+       libxfs_btree_del_cursor(bt_cur, XFS_BTREE_NOERROR);
+err_agf:
+       libxfs_buf_relse(agbp);
+err_pag:
+       libxfs_perag_put(pag);
        free_slab_cursor(&rm_cur);
 }