efi: Avoid a memory leak in efi_bind_block() on error path
Free the memory used if an error occurs. Series-to: u-boot Series-cc: Matthew Garrett <mgarrett@aurora.tech>, efi Cover-letter: efi: Add docs and tests and a few tweaks This series addresses feedback provided on the original series, including: - adding documentation and tests for the two new commands - fixing an issue that somehow didn't fail in CI - splitting up a large function into two parts - using lmb for the allocation, instead of looking at internal tables - dropping use of config.h Link: https://lore.kernel.org/u-boot/20241123195616.305687-1-mjg59@srcf.ucam.org/ Link: https://patchwork.ozlabs.org/project/uboot/list/?series=433949&state=*&archive=both END Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -60,8 +60,10 @@ int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio,
|
||||
plat->handle = handle;
|
||||
plat->blkio = blkio;
|
||||
plat->device_path = malloc(device_path_len);
|
||||
if (!plat->device_path)
|
||||
if (!plat->device_path) {
|
||||
free(plat);
|
||||
return log_msg_ret("path", -ENOMEM);
|
||||
}
|
||||
memcpy(plat->device_path, device_path, device_path_len);
|
||||
|
||||
snprintf(name, sizeof(name), "efi_media_%x",
|
||||
|
||||
Reference in New Issue
Block a user