* [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles
@ 2025-05-29 16:17 Khalid Ali
2025-06-06 8:20 ` sudhakar
0 siblings, 1 reply; 7+ messages in thread
From: Khalid Ali @ 2025-05-29 16:17 UTC (permalink / raw)
To: grub-devel; +Cc: Khalid Ali
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)
- return;
+ break;
port->name = grub_malloc (sizeof ("efiXXXXXXXXXXXXXXXXXXXX"));
if (!port->name)
{
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;
}
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles
2025-05-29 16:17 [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles Khalid Ali
@ 2025-06-06 8:20 ` sudhakar
2025-06-06 11:46 ` Khalid Ali
0 siblings, 1 reply; 7+ messages in thread
From: sudhakar @ 2025-06-06 8:20 UTC (permalink / raw)
To: The development of GNU GRUB; +Cc: Khalid Ali
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles
2025-06-06 8:20 ` sudhakar
@ 2025-06-06 11:46 ` Khalid Ali
0 siblings, 0 replies; 7+ messages in thread
From: Khalid Ali @ 2025-06-06 11:46 UTC (permalink / raw)
To: grub-devel
> Hi Khalid Ali,
> For pointers, you have to use like port == NULL instead !port
Hi Sudhakar Kuppusamy,
Well i checked on entire source tree to look for some consistency pattern,
and basically both are valid and used. I think it is matter of code author
preference. Beside i didn't write the code, i was just fixing memory leaks.
The code was already existed.
Regards, Khalid
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles
@ 2025-07-10 17:06 Khalid Ali
0 siblings, 0 replies; 7+ messages in thread
From: Khalid Ali @ 2025-07-10 17:06 UTC (permalink / raw)
To: grub-devel; +Cc: Khalid Ali
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)
- return;
+ break;
port->name = grub_malloc (sizeof ("efiXXXXXXXXXXXXXXXXXXXX"));
if (!port->name)
{
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;
}
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles
@ 2025-12-15 16:59 Khalid Ali
2025-12-19 7:05 ` Sudhakar Kuppusamy
0 siblings, 1 reply; 7+ messages in thread
From: Khalid Ali @ 2025-12-15 16:59 UTC (permalink / raw)
To: grub-devel; +Cc: Khalid Ali
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)
- return;
+ break;
port->name = grub_malloc (sizeof ("efiXXXXXXXXXXXXXXXXXXXX"));
if (!port->name)
{
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;
}
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles
2025-12-15 16:59 Khalid Ali
@ 2025-12-19 7:05 ` Sudhakar Kuppusamy
2025-12-20 14:18 ` Daniel Kiper
0 siblings, 1 reply; 7+ messages in thread
From: Sudhakar Kuppusamy @ 2025-12-19 7:05 UTC (permalink / raw)
To: The development of GNU GRUB; +Cc: Khalid Ali
> On 15 Dec 2025, at 10:29 PM, Khalid Ali <khaliidcaliy@gmail.com> 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>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Thanks,
Sudhakar
> ---
> 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)
> - return;
> + break;
>
> port->name = grub_malloc (sizeof ("efiXXXXXXXXXXXXXXXXXXXX"));
> if (!port->name)
> {
> 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;
> }
>
> --
> 2.49.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles
2025-12-19 7:05 ` Sudhakar Kuppusamy
@ 2025-12-20 14:18 ` Daniel Kiper
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Kiper @ 2025-12-20 14:18 UTC (permalink / raw)
To: Sudhakar Kuppusamy; +Cc: The development of GNU GRUB, Khalid Ali
On Fri, Dec 19, 2025 at 12:35:37PM +0530, Sudhakar Kuppusamy wrote:
> > On 15 Dec 2025, at 10:29 PM, Khalid Ali <khaliidcaliy@gmail.com> 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>
>
> Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Daniel
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-12-20 14:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-29 16:17 [RESEND PATCH] UEFI: Fix several memory leaks of UEFI handles Khalid Ali
2025-06-06 8:20 ` sudhakar
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
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.