aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_file.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt2023-07-30 14:03:53 +0200
committerHeinrich Schuchardt2023-08-03 09:21:03 +0200
commitcff7700170c2eb9d8059acbc2a5664ee9c8a8a9b (patch)
tree816c770d332a8dbbd9bbe32691253df2f839eedd /lib/efi_loader/efi_file.c
parentecae4bbf35fac3cde0c41c012a05c8e5b4ade90f (diff)
efi_loader: error handling in efi_disk_add_dev
* If an error occurs in efi_disk_add_dev(), don't leak resources. * If calloc() fails while creating the file system protocol interface, signal an error. * Rename efi_simple_file_system() to efi_create_simple_file_system(). * Drop a little helpful debug message. Fixes: 2a92080d8c44 ("efi_loader: add file/filesys support") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'lib/efi_loader/efi_file.c')
-rw-r--r--lib/efi_loader/efi_file.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 520c730220a..3764a92b50f 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -1192,18 +1192,22 @@ efi_open_volume(struct efi_simple_file_system_protocol *this,
return EFI_EXIT(efi_open_volume_int(this, root));
}
-struct efi_simple_file_system_protocol *
-efi_simple_file_system(struct blk_desc *desc, int part,
- struct efi_device_path *dp)
+efi_status_t
+efi_create_simple_file_system(struct blk_desc *desc, int part,
+ struct efi_device_path *dp,
+ struct efi_simple_file_system_protocol **fsp)
{
struct file_system *fs;
fs = calloc(1, sizeof(*fs));
+ if (!fs)
+ return EFI_OUT_OF_RESOURCES;
fs->base.rev = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;
fs->base.open_volume = efi_open_volume;
fs->desc = desc;
fs->part = part;
fs->dp = dp;
+ *fsp = &fs->base;
- return &fs->base;
+ return EFI_SUCCESS;
}