From 2be617b58b500214d45c338eda88237730524cac Mon Sep 17 00:00:00 2001 From: Jacob Garber Date: Tue, 7 May 2019 19:49:37 -0600 Subject: util/intelvbttool: Free file object on error path Prevents a memory leak. Found-by: Coverity Scan #1396047 Signed-off-by: Jacob Garber Change-Id: I4c72a17351d8afbe23302edfeeba74b17608aef2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/32685 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Rudolph --- util/intelvbttool/intelvbttool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'util') 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"); -- cgit v1.2.3