Skip to contentSkip to conversation

commands/efi: Fix sevral memory leaks

PATCH In review khaalid cali 2 participants 3 messages May 20, 2025 – May 22, 2025

lore
Share & tools
lore
#0 lore raw

cover commands/efi: Fix sevral memory leaks

"handles" that "grub_efi_locate_handles" was allocated with "grub_malloc" wasn't being freed.

---
 grub-core/commands/efi/lsefi.c | 1 +
 grub-core/commands/efi/tpm.c   | 2 ++
 2 files changed, 3 insertions(+)
grub-core/commands/efi/lsefi.c +1 -0
index 7b8316d41..68561f9b6 100644
@@ -129,6 +129,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
 
     }
 
+    grub_free (handles);
   return 0;
 }
 
grub-core/commands/efi/tpm.c +2 -0
index cbac69866..cb39b7bba 100644
@@ -112,6 +112,7 @@ grub_tpm_handle_find (grub_efi_handle_t *tpm_handle,
       grub_tpm_version = 1;
       *protocol_version = 1;
       grub_dprintf ("tpm", "TPM handle Found, version: 1\n");
+      grub_free (handles);
       return 1;
     }
 
@@ -124,6 +125,7 @@ grub_tpm_handle_find (grub_efi_handle_t *tpm_handle,
       grub_tpm_version = 2;
       *protocol_version = 2;
       grub_dprintf ("tpm", "TPM handle Found, version: 2\n");
+      grub_free (handles);
       return 1;
     }
 
Signature · 7 lines
2.49.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#2 lore raw
In reply to khaalid cali
Quoted 1 line · khaalid cali

"handles" that "grub_efi_locate_handles" was allocated with "grub_malloc" wasn't being freed.

The "handles" allocated by grub_efi_locate_handle() call are not always freed. Add missing grub_free() calls.

Quoted 5 lines
---
 grub-core/commands/efi/lsefi.c | 1 +
 grub-core/commands/efi/tpm.c   | 2 ++

This patch is not complete. At least one grub_free() call is missing in grub-core/video/efi_gop.c:check_protocol().

Daniel

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