Skip to contentSkip to conversation

lsefi: fixed memory leaks

PATCH Superseded Renaud Métrich via Grub-devel 3 participants 3 messages Jun 10, 2025 – Jun 18, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lsefi: fixed memory leaks

---
 grub-core/commands/efi/lsefi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
grub-core/commands/efi/lsefi.c +5 -1
index 7b8316d41..a70f243d0 100644
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2012  Free Software Foundation, Inc.
+ *  Copyright (C) 2025  Free Software Foundation, Inc.
  *
  *  GRUB is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -127,8 +127,12 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
 	    grub_printf ("  %pG\n", protocols[j]);
 	}
 
+      if (protocols)
+	grub_efi_free_pool (protocols);
     }
 
+  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 19 lines · Renaud Métrich via Grub-devel
---
 grub-core/commands/efi/lsefi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
grub-core/commands/efi/lsefi.c +1 -1
index 7b8316d41..a70f243d0 100644
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2012  Free Software Foundation, Inc.
+ *  Copyright (C) 2025  Free Software Foundation, Inc.
  *
  *  GRUB is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published 

by

grub-core/commands/efi/lsefi.c grub_cmd_lsefi (grub_command_t cmd __attribute__ · line 132

Quoted 6 lines
grub-core/commands/efi/lsefi.c +2 -0
@@ -127,8 +127,12 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__
 ((unused)),
 	    grub_printf ("  %pG\n", protocols[j]);
 	}
 
+      if (protocols)
+	grub_efi_free_pool (protocols);

Hi Renaud Métrich,

better to use like this

     if (protocols != NULL)
       grub_efi_free_pool (protocols);

thanks,
Sudhakar

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

Quoted 6 lines
grub-core/commands/efi/lsefi.c +2 -0
     }
 
+  grub_free (handles);
+
   return 0;
 }

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

#2 lore raw
In reply to Renaud Métrich via Grub-devel
Quoted 18 lines · Renaud Métrich via Grub-devel
---
 grub-core/commands/efi/lsefi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
grub-core/commands/efi/lsefi.c +1 -1
index 7b8316d41..a70f243d0 100644
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2012  Free Software Foundation, Inc.
+ *  Copyright (C) 2025  Free Software Foundation, Inc.
  *
  *  GRUB is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by

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 +2 -0
@@ -127,8 +127,12 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
 	    grub_printf ("  %pG\n", protocols[j]);
 	}
 
+      if (protocols)
+	grub_efi_free_pool (protocols);

How many times have I to say this function does not exist in GRUB upstream? This shows you even did not build the GRUB with this change before sending the email...

Daniel

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