diff options
author | Cyril Bur <cyril.bur@au1.ibm.com> | 2015-11-11 15:39:56 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-11-16 12:57:27 +1100 |
commit | 434ff83aebe4ebca02119911ad0d8e3e4308be22 (patch) | |
tree | e521603a98f2f7bf1e99701b1ac93df02c5e498f /external | |
parent | e8c3b060d457525b3ca9f1c29da4b8ae82d1013e (diff) | |
download | skiboot-434ff83aebe4ebca02119911ad0d8e3e4308be22.zip skiboot-434ff83aebe4ebca02119911ad0d8e3e4308be22.tar.gz skiboot-434ff83aebe4ebca02119911ad0d8e3e4308be22.tar.bz2 |
external/gard: Fix memory leak
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/gard/gard.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/external/gard/gard.c b/external/gard/gard.c index 4e891f3..b656f40 100644 --- a/external/gard/gard.c +++ b/external/gard/gard.c @@ -710,7 +710,8 @@ int main(int argc, char **argv) break; case '?': usage(progname); - return EXIT_FAILURE; + rc = EXIT_FAILURE; + goto out_free; } } @@ -726,7 +727,8 @@ int main(int argc, char **argv) /* do we have a command? */ if (optind == argc) { usage(progname); - return EXIT_FAILURE; + rc = EXIT_FAILURE; + goto out_free; } argc -= optind; @@ -735,8 +737,10 @@ int main(int argc, char **argv) if (!filename) { rc = get_dev_mtd(fdt_flash_path, &filename); - if (rc) - return EXIT_FAILURE; + if (rc) { + rc = EXIT_FAILURE; + goto out_free; + } } rc = file_init_path(filename, NULL, &(ctx->bl)); @@ -786,7 +790,6 @@ int main(int argc, char **argv) } out: - free(filename); if (ctx->ffs) ffs_close(ctx->ffs); @@ -795,7 +798,8 @@ out: if (i == ARRAY_SIZE(actions)) { fprintf(stderr, "%s: '%s' isn't a valid command\n", progname, action); usage(progname); - return EXIT_FAILURE; + rc = EXIT_FAILURE; + goto out_free; } if (rc > 0) { @@ -803,5 +807,8 @@ out: if (filename && rc == FFS_ERR_BAD_MAGIC) fprintf(stderr, "Maybe you didn't give a full flash image file?\nDid you mean '--part'?\n"); } + +out_free: + free(filename); return rc; } |