All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Maiolino <cem@kernel.org>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 2/2] xfs_repair: Fix rmaps_verify_btree() error path
Date: Fri,  2 Sep 2022 15:43:48 +0200	[thread overview]
Message-ID: <166212622823.31305.7621804364378399970.stgit@andromeda> (raw)
In-Reply-To: <166212614879.31305.11337231919093625864.stgit@andromeda>

From: Carlos Maiolino <cmaiolino@redhat.com>

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>
---
 repair/rmap.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/repair/rmap.c b/repair/rmap.c
index 0253c0c36..8b76e290b 100644
--- a/repair/rmap.c
+++ b/repair/rmap.c
@@ -1002,7 +1002,7 @@ rmaps_verify_btree(
 	if (error) {
 		do_warn(_("Could not read AGF %u to check rmap btree.\n"),
 				agno);
-		goto err;
+		goto err_agf;
 	}
 
 	/* Leave the per-ag data "uninitialized" since we rewrite it later */
@@ -1011,7 +1011,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_bt_cur;
 	}
 
 	rm_rec = pop_slab_cursor(rm_cur);
@@ -1021,7 +1021,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_loop;
 		}
 
 		/*
@@ -1037,7 +1037,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_loop;
 			}
 		}
 		if (!have) {
@@ -1088,13 +1088,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_loop:
+	libxfs_btree_del_cursor(bt_cur, XFS_BTREE_NOERROR);
+err_bt_cur:
+	libxfs_buf_relse(agbp);
+err_agf:
+	libxfs_perag_put(pag);
 	free_slab_cursor(&rm_cur);
 }
 


  parent reply	other threads:[~2022-09-02 14:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 13:43 [PATCH 0/2] xfsprogs: fix covscan issues Carlos Maiolino
2022-09-02 13:43 ` [PATCH 1/2] xfs_repair: Fix check_refcount() error path Carlos Maiolino
2022-09-02 20:48   ` Darrick J. Wong
2022-09-05  7:05     ` Carlos Maiolino
2022-11-09 11:28       ` Carlos Maiolino
2022-11-09 16:10         ` Darrick J. Wong
2022-09-02 13:43 ` Carlos Maiolino [this message]
2022-11-28 13:14 [PATCH V2 0/2] xfsprogs: fix covscan issues cem
2022-11-28 13:14 ` [PATCH 2/2] xfs_repair: Fix rmaps_verify_btree() error path cem
2022-12-01  9:34 [PATCH V3 0/2] xfsprogs: fix covscan issues cem
2022-12-01  9:34 ` [PATCH 2/2] xfs_repair: Fix rmaps_verify_btree() error path cem
2022-12-01 15:33   ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=166212622823.31305.7621804364378399970.stgit@andromeda \
    --to=cem@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.