> On 15 Dec 2025, at 10:29 PM, Khalid Ali <[email protected]> wrote:
> 
> Fix possible and absolute memory leaks of "handles"
> returned by grub_efi_locate_handle() using grub_malloc().
> 
> Signed-off-by: Khalid Ali <[email protected]>

Reviewed-by: Sudhakar Kuppusamy <[email protected]>

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
> [email protected]
> https://lists.gnu.org/mailman/listinfo/grub-devel


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

Reply via email to