]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: catch out of memory in file_open
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 30 Jul 2023 12:06:06 +0000 (14:06 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 3 Aug 2023 07:21:03 +0000 (09:21 +0200)
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>
lib/efi_loader/efi_file.c

index 3764a92b50f0623491293948077616608e762c62..3c56cebf96530353192b45156e5211b49563729a 100644 (file)
@@ -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;