From: "Renaud Métrich via Grub-devel" <grub-devel@gnu.org>
To: grub-devel@gnu.org
Cc: "Renaud Métrich" <rmetrich@redhat.com>, dkiper@net-space.pl
Subject: [PATCH v2] lsefi: fixed memory leaks
Date: Tue, 2 Sep 2025 13:55:15 +0200 [thread overview]
Message-ID: <20250902115514.415430-2-rmetrich@redhat.com> (raw)
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
---
grub-core/commands/efi/lsefi.c | 4 ++++
include/grub/efi/efi.h | 27 +++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c
index 7b8316d41..bda25a3a9 100644
--- a/grub-core/commands/efi/lsefi.c
+++ b/grub-core/commands/efi/lsefi.c
@@ -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;
}
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index b4d2f2d46..538bdcda8 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -71,6 +71,7 @@ EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size,
grub_efi_uintn_t *descriptor_size,
grub_efi_uint32_t *descriptor_version);
void grub_efi_memory_fini (void);
+
grub_efi_loaded_image_t *EXPORT_FUNC(grub_efi_get_loaded_image) (grub_efi_handle_t image_handle);
void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp);
char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp);
@@ -193,4 +194,30 @@ struct grub_net_card;
grub_efi_handle_t
grub_efinet_get_device_handle (struct grub_net_card *card);
+static inline grub_efi_status_t
+__attribute__((__unused__))
+grub_efi_allocate_pool (grub_efi_memory_type_t pool_type,
+ grub_efi_uintn_t buffer_size,
+ void **buffer)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_status_t status;
+
+ b = grub_efi_system_table->boot_services;
+ status = b->allocate_pool(pool_type, buffer_size, buffer);
+ return status;
+}
+
+static inline grub_efi_status_t
+__attribute__((__unused__))
+grub_efi_free_pool (void *buffer)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_status_t status;
+
+ b = grub_efi_system_table->boot_services;
+ status = b->free_pool(buffer);
+ return status;
+}
+
#endif /* ! GRUB_EFI_EFI_HEADER */
--
2.51.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next reply other threads:[~2025-09-02 13:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 11:55 Renaud Métrich via Grub-devel [this message]
2025-09-02 11:59 ` [PATCH v2] lsefi: fixed memory leaks Renaud Métrich via Grub-devel
2025-09-04 13:59 ` Daniel Kiper
2025-09-09 12:09 ` Renaud Métrich via Grub-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250902115514.415430-2-rmetrich@redhat.com \
--to=grub-devel@gnu.org \
--cc=dkiper@net-space.pl \
--cc=rmetrich@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).