From: Darrick J. Wong Date: Fri, 18 Aug 2017 17:00:01 +0000 (-0500) Subject: xfs_db: free field list when failing out of fuzz X-Git-Tag: v4.13.0-rc1~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6a07c22c2486ebe6808f45cbe6aef3d0dfbce2cf;p=thirdparty%2Fxfsprogs-dev.git xfs_db: free field list when failing out of fuzz 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 Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- diff --git a/db/fuzz.c b/db/fuzz.c index a9b157703..76dbf940a 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); }