summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-05-07 19:49:37 -0600
committerPatrick Georgi <pgeorgi@google.com>2019-05-13 09:12:27 +0000
commit2be617b58b500214d45c338eda88237730524cac (patch)
treeb5182fad089ec2eac10fae6a0c2e4adc95af7de4
parent9bb0461fbd8cdcceabde0ec266a5207bc40ea9a7 (diff)
downloadcoreboot-2be617b58b500214d45c338eda88237730524cac.tar.xz
util/intelvbttool: Free file object on error path
Prevents a memory leak. Found-by: Coverity Scan #1396047 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Change-Id: I4c72a17351d8afbe23302edfeeba74b17608aef2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/32685 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Rudolph <siro@das-labor.org>
-rw-r--r--util/intelvbttool/intelvbttool.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/util/intelvbttool/intelvbttool.c b/util/intelvbttool/intelvbttool.c
index f8e4bda0f4..715b39ad57 100644
--- a/util/intelvbttool/intelvbttool.c
+++ b/util/intelvbttool/intelvbttool.c
@@ -1028,8 +1028,10 @@ static int patch_vbios(struct fileobject *fo,
if (old_vbt) {
if (oh->vbt_offset + vbt_size(old_vbt) == fo->size) {
/* Located at the end of file - reduce file size */
- if (fo->size < vbt_size(old_vbt))
+ if (fo->size < vbt_size(old_vbt)) {
+ free_fo(old_vbt);
return 1;
+ }
fo = remalloc_fo(fo, fo->size - vbt_size(old_vbt));
if (!fo) {
printerr("Failed to allocate memory\n");