* [PATCH 1/1] efi_loader: catch out of memory in file_open
@ 2023-07-30 12:07 Heinrich Schuchardt
2023-07-31 8:08 ` Ilias Apalodimas
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2023-07-30 12:07 UTC (permalink / raw)
To: Ilias Apalodimas; +Cc: u-boot, Heinrich Schuchardt
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>
---
lib/efi_loader/efi_file.c | 2 ++
1 file changed, 2 insertions(+)
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;
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] efi_loader: catch out of memory in file_open
2023-07-30 12:07 [PATCH 1/1] efi_loader: catch out of memory in file_open Heinrich Schuchardt
@ 2023-07-31 8:08 ` Ilias Apalodimas
0 siblings, 0 replies; 2+ messages in thread
From: Ilias Apalodimas @ 2023-07-31 8:08 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: u-boot
On Sun, 30 Jul 2023 at 15:07, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> 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>
> ---
> lib/efi_loader/efi_file.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> 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;
> --
> 2.40.1
>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-31 8:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-30 12:07 [PATCH 1/1] efi_loader: catch out of memory in file_open Heinrich Schuchardt
2023-07-31 8:08 ` Ilias Apalodimas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.