mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
UPSTREAM: libpayload: cbfs: Fix minor memory leak in some edge cases
cbfs_get_handle() allocates memory for a handle and doesn't free it if it errors out later, leaving the memory permanently leaked. Fix. BUG=None BRANCH=None TEST=None Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/16207 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Change-Id: Ide198105ce3ad6237672ff152b4490c768909564 Reviewed-on: https://chromium-review.googlesource.com/369153 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
dd5b637bda
commit
e10e635726
1 changed files with 3 additions and 0 deletions
|
@ -148,6 +148,7 @@ struct cbfs_handle *cbfs_get_handle(struct cbfs_media *media, const char *name)
|
|||
|
||||
if (get_cbfs_range(&offset, &cbfs_end, media)) {
|
||||
ERROR("Failed to find cbfs range\n");
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -155,6 +156,7 @@ struct cbfs_handle *cbfs_get_handle(struct cbfs_media *media, const char *name)
|
|||
media = &handle->media;
|
||||
if (init_default_cbfs_media(media) != 0) {
|
||||
ERROR("Failed to initialize default media.\n");
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -215,6 +217,7 @@ struct cbfs_handle *cbfs_get_handle(struct cbfs_media *media, const char *name)
|
|||
}
|
||||
media->close(media);
|
||||
LOG("WARNING: '%s' not found.\n", name);
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue