mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-09-26 08:11:25 +02:00
tools/fit_image.c: Update some return code paths
Coverity has found some problems with the return paths in parts of this code. We have a case where we were going to the wrong part of the unwind (open() failed so we cannot close the fd), a case where we were only free()ing our buf on the error path and finally a case where we did not munmap in the failure path. Reported-by: Coverity (CID: 138492, 138495, 143064) Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
146dda3911
commit
3c2dff5490
@ -372,7 +372,7 @@ static int fit_build(struct image_tool_params *params, const char *fname)
|
|||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "%s: Can't open %s: %s\n",
|
fprintf(stderr, "%s: Can't open %s: %s\n",
|
||||||
params->cmdname, fname, strerror(errno));
|
params->cmdname, fname, strerror(errno));
|
||||||
goto err;
|
goto err_buf;
|
||||||
}
|
}
|
||||||
ret = write(fd, buf, size);
|
ret = write(fd, buf, size);
|
||||||
if (ret != size) {
|
if (ret != size) {
|
||||||
@ -501,6 +501,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
|
|||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
free(buf);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -601,6 +602,7 @@ static int fit_import_data(struct image_tool_params *params, const char *fname)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
munmap(old_fdt, sbuf.st_size);
|
||||||
free(fdt);
|
free(fdt);
|
||||||
close(fd);
|
close(fd);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user