Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/33961 )
Change subject: util/amdfwtool: Close file descriptor on error ......................................................................
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 --- M util/amdfwtool/amdfwtool.c 1 file changed, 2 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved Paul Menzel: Looks good to me, but someone else must approve
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index 37dbcd0..e8ac0b1 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -566,11 +566,13 @@
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; }