Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] xfs_db: free field list when failing out of fuzz
Date: Sat, 5 Aug 2017 09:11:22 -0700	[thread overview]
Message-ID: <20170805161122.GK24087@magnolia> (raw)

Fix a missed opportunity to free the field list when we fail out of the
fuzz command by refactoring the error clauses to use a common cleanup
clause.

Fixes-coverity-id: 1416141
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 db/fuzz.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/db/fuzz.c b/db/fuzz.c
index a9b1577..76dbf94 100644
--- a/db/fuzz.c
+++ b/db/fuzz.c
@@ -400,7 +400,7 @@ fuzz_struct(
 			break;
 	if (fc->fn == NULL) {
 		dbprintf(_("Unknown fuzz command '%s'.\n"), argv[1]);
-		return;
+		goto out_free;
 	}
 
 	/* if we're a root field type, go down 1 layer to get field list */
@@ -412,9 +412,8 @@ fuzz_struct(
 
 	/* run down the field list and set offsets into the data */
 	if (!flist_parse(fields, fl, iocur_top->data, 0)) {
-		flist_free(fl);
 		dbprintf(_("parsing error\n"));
-		return;
+		goto out_free;
 	}
 
 	sfl = fl;
@@ -447,8 +446,7 @@ fuzz_struct(
 	success = fc->fn(iocur_top->data, sfl->offset, bit_length);
 	if (!success) {
 		dbprintf(_("unable to fuzz field '%s'\n"), argv[0]);
-		flist_free(fl);
-		return;
+		goto out_free;
 	}
 
 	/* Write the fuzzed value back */
@@ -456,5 +454,6 @@ fuzz_struct(
 
 	flist_print(fl);
 	print_flist(fl);
+out_free:
 	flist_free(fl);
 }

             reply	other threads:[~2017-08-05 16:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-05 16:11 Darrick J. Wong [this message]
2017-08-11 11:24 ` [PATCH] xfs_db: free field list when failing out of fuzz Christoph Hellwig

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=20170805161122.GK24087@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox