commit | 3a62b65de04554c70b352b351d9c715a2465493b | [log] [tgz] |
---|---|---|
author | Patrick Georgi <pgeorgi@google.com> | Thu Sep 26 18:21:01 2019 +0200 |
committer | Commit Bot <commit-bot@chromium.org> | Fri Sep 27 02:53:04 2019 +0000 |
tree | f3b5d4fd14e7eb4d1edce28e5e8bddf5443eef84 | |
parent | e3f424e136249b820be7e6098fbb37f44266cf10 [diff] |
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>
diff --git a/host/arch/x86/lib/crossystem_arch.c b/host/arch/x86/lib/crossystem_arch.c index 3151064..c745e0b 100644 --- a/host/arch/x86/lib/crossystem_arch.c +++ b/host/arch/x86/lib/crossystem_arch.c
@@ -245,12 +245,16 @@ 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)