Skip to contentSkip to conversation

commands/efi/lsefi: Fix memory leak

PATCH Superseded khaalid cali 2 participants 2 messages May 13, 2025 – May 16, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover commands/efi/lsefi: Fix memory leak

From: khaalid <[email protected]>

It was forgotten to free handles array of handles returned by
grub_efi_locate_handle. This is quite a large amount of memory, it depends how many handles being returned which can be hundrends.

---
 grub-core/commands/efi/lsefi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/commands/efi/lsefi.c +1 -1
index 7b8316d41..016f3eafe 100644
@@ -128,7 +128,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
 	}
 
     }
-
+    grub_free(handles);
   return 0;
 }
 
Signature · 7 lines
2.49.0


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

From: khaalid <[email protected]>

You can drop this if it is your patch.

Quoted 1 line

It was forgotten to free handles array of handles returned by

Please use " instead of ` and/or '.

Quoted 1 line

grub_efi_locate_handle. This is quite a large amount of memory, it depends how many handles being returned which can be hundrends.

Please wrap lines more or less at 80 characters.

Quoted 10 lines
---
 grub-core/commands/efi/lsefi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/commands/efi/lsefi.c +0 -0
index 7b8316d41..016f3eafe 100644

grub-core/commands/efi/lsefi.c grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)), · line 131

Quoted 5 lines
grub-core/commands/efi/lsefi.c +1 -1
@@ -128,7 +128,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
 	}
 
     }
-
+    grub_free(handles);

Good catch!

Could you fix indention and add space before "("? [1]

Additionally, I can see similar issues around grub_efi_locate_handle() calls in other places too, e.g., grub-core/commands/efi/tpm.c. Could you fix that too? You can do that in the same patch.

grub-core/commands/efi/lsefi.c grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)), · line 133

Quoted 2 lines
grub-core/commands/efi/lsefi.c +0 -0
   return 0;
 }

Daniel

[1] https://www.gnu.org/software/grub/manual/grub-dev/grub-dev.html#Coding-style

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