cbfstool: Fix possible memory leak
Handle the possible memory leak scenario. Foundby=klocwork BUG=NONE TEST=Boot to OS on Nivviks Change-Id: I01c4643d1e671d9bd9971ac6db8031634fffd61e Signed-off-by: Shaik Shahina <shahina.shaik@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/69220 Reviewed-by: Shahina Shaik <shahina.shaik@intel.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
This commit is contained in:
parent
5c1dcd57ee
commit
425413c35f
|
@ -771,7 +771,7 @@ static int cbfs_add_master_header(void)
|
||||||
if (param.topswap_size) {
|
if (param.topswap_size) {
|
||||||
if (update_master_header_loc_topswap(&image, h_loc,
|
if (update_master_header_loc_topswap(&image, h_loc,
|
||||||
header_offset))
|
header_offset))
|
||||||
return 1;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = maybe_update_metadata_hash(&image);
|
ret = maybe_update_metadata_hash(&image);
|
||||||
|
|
|
@ -34,8 +34,13 @@ int buffer_create(struct buffer *buffer, size_t size, const char *name)
|
||||||
if (!buffer->data) {
|
if (!buffer->data) {
|
||||||
fprintf(stderr, "buffer_create: Insufficient memory (0x%zx).\n",
|
fprintf(stderr, "buffer_create: Insufficient memory (0x%zx).\n",
|
||||||
size);
|
size);
|
||||||
|
if (buffer->name) {
|
||||||
|
free(buffer->name);
|
||||||
|
buffer->name = NULL;
|
||||||
}
|
}
|
||||||
return (buffer->data == NULL);
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int buffer_from_file_aligned_size(struct buffer *buffer, const char *filename,
|
int buffer_from_file_aligned_size(struct buffer *buffer, const char *filename,
|
||||||
|
|
Loading…
Reference in New Issue