From: Heinrich Schuchardt Date: Sun, 30 Jul 2023 12:06:06 +0000 (+0200) Subject: efi_loader: catch out of memory in file_open X-Git-Tag: v2025.01-rc5-pxa1908~902^2~1 X-Git-Url: http://git.dujemihanovic.xyz/img/html/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=405b736e817bbca360b2fd3329953d3980585df2;p=u-boot.git 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 Reviewed-by: Ilias Apalodimas --- 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;