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>
This commit is contained in:
Jacob Garber 2019-05-07 19:49:37 -06:00 committed by Patrick Georgi
parent 9bb0461fbd
commit 2be617b58b
1 changed files with 3 additions and 1 deletions

View File

@ -1028,8 +1028,10 @@ static int patch_vbios(struct fileobject *fo,
if (old_vbt) { if (old_vbt) {
if (oh->vbt_offset + vbt_size(old_vbt) == fo->size) { if (oh->vbt_offset + vbt_size(old_vbt) == fo->size) {
/* Located at the end of file - reduce file 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; return 1;
}
fo = remalloc_fo(fo, fo->size - vbt_size(old_vbt)); fo = remalloc_fo(fo, fo->size - vbt_size(old_vbt));
if (!fo) { if (!fo) {
printerr("Failed to allocate memory\n"); printerr("Failed to allocate memory\n");