summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-07-02 10:35:10 -0600
committerPatrick Georgi <pgeorgi@google.com>2019-07-10 18:21:41 +0000
commit967f862e47e26cd07b6b43eda6e1445f58e8989b (patch)
treec91581d86f84b7be026d7096bfba2240fa680a1b
parent3dbaf4f33646dc2e0ae9aaa8f4c8570d50a04c27 (diff)
downloadcoreboot-967f862e47e26cd07b6b43eda6e1445f58e8989b.tar.xz
util/amdfwtool: Close file descriptor on error
Prevents a resource leak. Change-Id: Id5da2df3e37cba499cd2e9a7c3ede34e4de2ed77 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Found-by: Coverity CID 1402139 Reviewed-on: https://review.coreboot.org/c/coreboot/+/33961 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
-rw-r--r--util/amdfwtool/amdfwtool.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index 37dbcd093f..e8ac0b1ae9 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -566,11 +566,13 @@ static ssize_t copy_blob(void *dest, const char *src_file, size_t room)
if (fstat(fd, &fd_stat)) {
printf("fstat error: %s\n", strerror(errno));
+ close(fd);
return -2;
}
if (fd_stat.st_size > room) {
printf("Error: %s will not fit. Exiting.\n", src_file);
+ close(fd);
return -3;
}