Skip to contentSkip to conversation

loader/efi/linux: Fix memory leak

PATCH In review khaalid cali 1 participant 1 message May 16, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/3 loader/efi/linux: Fix memory leak

From: khaalid <[email protected]>

Free "mempath" in case of failures.

---
 grub-core/loader/efi/linux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
grub-core/loader/efi/linux.c +7 -0
index 7c7db3e3a..507d3a343 100644
@@ -213,7 +213,7 @@ grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args)
 			  (void *) addr, size, &image_handle);
   if (status != GRUB_EFI_SUCCESS)
+   {
+    grub_free (mempath);
     return grub_error (GRUB_ERR_BAD_OS, "cannot load image 0x%lx", status);
+   }
     
@@ -232,7 +232,7 @@ grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args)
     grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (len));
   if (!loaded_image->load_options)
+   {
+    grub_free (mempath);
     return grub_errno;
+   }
 
@@ -248,7 +248,7 @@ grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args)
   grub_efi_free_pages ((grub_addr_t) loaded_image->load_options,
 		       GRUB_EFI_BYTES_TO_PAGES (len));
   loaded_image->load_options = NULL;
+  grub_free (mempath);
 unload:
   b->unload_image (image_handle);
 
Signature · 7 lines
2.49.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel