diff options
author | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2023-07-30 14:06:06 +0200 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2023-08-03 09:21:03 +0200 |
commit | 405b736e817bbca360b2fd3329953d3980585df2 (patch) | |
tree | 589a012803d978539f309bc026d90fe4d7aca5b3 /lib/efi_loader | |
parent | cff7700170c2eb9d8059acbc2a5664ee9c8a8a9b (diff) | |
download | u-boot-405b736e817bbca360b2fd3329953d3980585df2.tar.gz u-boot-405b736e817bbca360b2fd3329953d3980585df2.tar.bz2 u-boot-405b736e817bbca360b2fd3329953d3980585df2.zip |
efi_loader: catch out of memory in file_open
If calloc() return NULL, don't dereference it.
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')
-rw-r--r-- | lib/efi_loader/efi_file.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index 3764a92b50..3c56cebf96 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -195,6 +195,8 @@ static struct efi_file_handle *file_open(struct file_system *fs, /* +2 is for null and '/' */ fh = calloc(1, sizeof(*fh) + plen + (flen * MAX_UTF8_PER_UTF16) + 2); + if (!fh) + return NULL; fh->open_mode = open_mode; fh->base = efi_file_handle_protocol; |