efi: Fix several memory leaks of UEFI handles
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>
This commit is contained in:
parent
c477a95519
commit
0f0899c329
@ -129,6 +129,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
}
|
||||
|
||||
grub_free (handles);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -113,6 +113,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;
|
||||
}
|
||||
|
||||
@ -125,6 +126,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;
|
||||
}
|
||||
|
||||
|
||||
@ -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++);
|
||||
|
||||
@ -94,7 +94,7 @@ check_protocol (void)
|
||||
gop_handle = 0;
|
||||
|
||||
grub_dprintf ("video", "GOP: no usable mode\n");
|
||||
|
||||
grub_free (handles);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user