diff options
author | Patrick Georgi <pgeorgi@google.com> | 2019-09-26 18:21:01 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-27 02:53:04 +0000 |
commit | 3a62b65de04554c70b352b351d9c715a2465493b (patch) | |
tree | f3b5d4fd14e7eb4d1edce28e5e8bddf5443eef84 | |
parent | e3f424e136249b820be7e6098fbb37f44266cf10 (diff) | |
download | vboot-3a62b65de04554c70b352b351d9c715a2465493b.tar.gz |
x86/crossystem_arch: Free file descriptor if we fail to use it
Found by Coverity Scan #204275
BUG=none
BRANCH=none
TEST=Coverity run after this merged marks #204275 fixed
Change-Id: I50e6300eabaf6bd0c1230b0cbd2d375ab1daf5d2
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1827293
Reviewed-by: Duncan Laurie <dlaurie@google.com>
Commit-Queue: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
-rw-r--r-- | host/arch/x86/lib/crossystem_arch.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/host/arch/x86/lib/crossystem_arch.c b/host/arch/x86/lib/crossystem_arch.c index 31510647..c745e0b4 100644 --- a/host/arch/x86/lib/crossystem_arch.c +++ b/host/arch/x86/lib/crossystem_arch.c @@ -245,12 +245,16 @@ static uint8_t* VbGetBuffer(const char* filename, int* buffer_size) break; rv = fstat(fd, &fs); - if (rv || !S_ISREG(fs.st_mode)) + if (rv || !S_ISREG(fs.st_mode)) { + close(fd); break; + } f = fdopen(fd, "r"); - if (!f) + if (!f) { + close(fd); break; + } file_buffer = malloc(fs.st_size + 1); if (!file_buffer) |