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>
This commit is contained in:
Jacob Garber 2019-07-02 10:35:10 -06:00 committed by Patrick Georgi
parent 3dbaf4f336
commit 967f862e47
1 changed files with 2 additions and 0 deletions

View File

@ -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;
}