From: Avnish Chouhan Date: Thu, 27 Nov 2025 09:02:12 +0000 (+0530) Subject: efiemu/loadcore: Add grub_calloc() failure check X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09c512b8fabdbc19d5698925c796c43def240bc0;p=thirdparty%2Fgrub.git efiemu/loadcore: Add grub_calloc() failure check Add a failure check after grub_calloc() call. If grub_calloc() fails, e.g., due to memory allocation failure, it returns NULL. Then using grub_efiemu_elfsyms, which will be NULL, later will result in a NULL pointer dereference. Signed-off-by: Avnish Chouhan Reviewed-by: Sudhakar Kuppusamy Reviewed-by: Daniel Kiper --- diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c index 2b924623f..4a091bee0 100644 --- a/grub-core/efiemu/loadcore.c +++ b/grub-core/efiemu/loadcore.c @@ -203,6 +203,9 @@ grub_efiemu_count_symbols (const Elf_Ehdr *e) grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *) grub_calloc (grub_efiemu_nelfsyms, sizeof (struct grub_efiemu_elf_sym)); + if (grub_efiemu_elfsyms == NULL) + return grub_errno; + /* Relocators */ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); i < e->e_shnum;