cbfstool/cbfs_image: Check for return value of buffer_create

Free any buffers if required.

Change-Id: Iccd435dba51275d875a5fdb5649cdcd0541fd84c
Signed-off-by: Furquan Shaikh <furquan@google.com>
Found-by: Coverity Scan # 1361254
Reviewed-on: https://review.coreboot.org/16073
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Furquan Shaikh 2016-08-05 08:27:18 -07:00 committed by Patrick Georgi
parent 7b405178f4
commit 58644a0e0f
1 changed files with 6 additions and 2 deletions

View File

@ -847,7 +847,8 @@ static int cbfs_payload_decompress(struct cbfs_payload_segment *segments,
for (int i = 0; i < num_seg; i++)
new_buff_sz += segments[i].mem_len;
buffer_create(&new_buffer, new_buff_sz, "decompressed_buff");
if (buffer_create(&new_buffer, new_buff_sz, "decompressed_buff"))
return -1;
in_ptr = buffer_get(buff) + new_offset;
out_ptr = buffer_get(&new_buffer) + new_offset;
@ -878,7 +879,10 @@ static int cbfs_payload_decompress(struct cbfs_payload_segment *segments,
continue;
}
buffer_create(&tbuff, segments[i].mem_len, "segment");
if (buffer_create(&tbuff, segments[i].mem_len, "segment")) {
buffer_delete(&new_buffer);
return -1;
}
if (decompress(in_ptr, segments[i].len, buffer_get(&tbuff),
(int) buffer_size(&tbuff),