From 828da3d55668edfc9b7d64e1d21dd0438fccfcd5 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Thu, 5 Oct 2017 15:44:24 +0200 Subject: [PATCH] util/iteflash.c: make sure that the file is closed An insignificant bug, but Coverity complains about it. Reduce the cognitive load by making sure that file is closed in time. BUG=none BRANCH=none TEST=none Change-Id: I2efbe136f4991cf829b95568eef22eb7b2d1a8c6 Found-by: Coverity Scan #141758 Signed-off-by: Patrick Georgi Reviewed-on: https://chromium-review.googlesource.com/702304 Commit-Ready: Patrick Georgi Tested-by: Patrick Georgi Reviewed-by: Chris Ching --- util/iteflash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/iteflash.c b/util/iteflash.c index 3011600f3f..701c9dd2a5 100644 --- a/util/iteflash.c +++ b/util/iteflash.c @@ -916,12 +916,12 @@ int verify_flash(struct ftdi_context *ftdi, const char *filename, } file_size = fread(buffer, 1, flash_size, hnd); + fclose(hnd); if (file_size <= 0) { fprintf(stderr, "Cannot read %s\n", filename); res = -EIO; goto exit; } - fclose(hnd); printf("Verify %d bytes at 0x%08x\n", file_size, offset); res = command_read_pages(ftdi, offset, flash_size, buffer2);