From: sudhakar <sudhakar@linux.ibm.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: Khalid Ali <khaliidcaliy@gmail.com>
Subject: Re: [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles
Date: Fri, 06 Jun 2025 13:50:33 +0530 [thread overview]
Message-ID: <4559a846b3301274b0dfecf8402f1bd9@linux.ibm.com> (raw)
In-Reply-To: <20250529161715.991-1-khaliidcaliy@gmail.com>
On 2025-05-29 21:47, Khalid Ali wrote:
> Fix possible and absolute memory leaks of "handles"
> returned by grub_efi_locate_handle() using grub_malloc().
>
> Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
> ---
> grub-core/commands/efi/lsefi.c | 1 +
> grub-core/commands/efi/tpm.c | 2 ++
> grub-core/term/efi/serial.c | 4 ++--
> grub-core/video/efi_gop.c | 2 +-
> 4 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/grub-core/commands/efi/lsefi.c
> b/grub-core/commands/efi/lsefi.c
> index 7b8316d41..f4c10392d 100644
> --- a/grub-core/commands/efi/lsefi.c
> +++ b/grub-core/commands/efi/lsefi.c
> @@ -129,6 +129,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__
> ((unused)),
>
> }
>
> + grub_free (handles);
> return 0;
> }
>
> diff --git a/grub-core/commands/efi/tpm.c
> b/grub-core/commands/efi/tpm.c
> index cbac69866..cb39b7bba 100644
> --- a/grub-core/commands/efi/tpm.c
> +++ b/grub-core/commands/efi/tpm.c
> @@ -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;
> }
>
> diff --git a/grub-core/term/efi/serial.c b/grub-core/term/efi/serial.c
> index 5dfd2d86c..e409b8d5e 100644
> --- a/grub-core/term/efi/serial.c
> +++ b/grub-core/term/efi/serial.c
> @@ -169,13 +169,13 @@ grub_efiserial_init (void)
>
> port = grub_zalloc (sizeof (*port));
> if (!port)
Hi Khalid Ali,
For pointers, you have to use like port == NULL instead !port
> - return;
> + break;
>
> port->name = grub_malloc (sizeof ("efiXXXXXXXXXXXXXXXXXXXX"));
> if (!port->name)
same above
port->name == NULL
> {
> grub_free (port);
> - return;
> + break;
> }
> grub_snprintf (port->name, sizeof ("efiXXXXXXXXXXXXXXXXXXXX"),
> "efi%d", num_serial++);
> diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c
> index 9452f5e58..1ad2e709d 100644
> --- a/grub-core/video/efi_gop.c
> +++ b/grub-core/video/efi_gop.c
> @@ -94,7 +94,7 @@ check_protocol (void)
> gop_handle = 0;
>
> grub_dprintf ("video", "GOP: no usable mode\n");
> -
> + grub_free (handles);
> return 0;
> }
Thanks,
Sudhakar Kuppusamy
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next prev parent reply other threads:[~2025-06-06 8:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-29 16:17 [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles Khalid Ali
2025-06-06 8:20 ` sudhakar [this message]
2025-06-06 11:46 ` Khalid Ali
-- strict thread matches above, loose matches on Subject: below --
2025-07-10 17:06 Khalid Ali
2025-12-15 16:59 Khalid Ali
2025-12-19 7:05 ` Sudhakar Kuppusamy
2025-12-20 14:18 ` Daniel Kiper
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=4559a846b3301274b0dfecf8402f1bd9@linux.ibm.com \
--to=sudhakar@linux.ibm.com \
--cc=grub-devel@gnu.org \
--cc=khaliidcaliy@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.