Commit 5b15a2596f7852177c7f451349b353e6e52742a2
Committed by
Tom Rini
1 parent
3bd3a54ac5
Exists in
v2017.01-smarct4x
and in
29 other branches
mkimage: Don't close the file if it wasn't opened
The error path for fit_import_data() is incorrect if the second open() call fails. Reported-by: Coverity (CID: 138489) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
tools/fit_image.c
... | ... | @@ -537,8 +537,8 @@ |
537 | 537 | if (fd < 0) { |
538 | 538 | fprintf(stderr, "%s: Can't open %s: %s\n", |
539 | 539 | params->cmdname, fname, strerror(errno)); |
540 | - ret = -EIO; | |
541 | - goto err; | |
540 | + free(fdt); | |
541 | + return -EIO; | |
542 | 542 | } |
543 | 543 | if (write(fd, fdt, new_size) != new_size) { |
544 | 544 | debug("%s: Failed to write external data to file %s\n", |