All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi/libstub/x86: Free EFI map buffer in allocate_e820()
@ 2020-05-05 19:00 Lenny Szubowicz
  2020-05-06  7:23 ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Lenny Szubowicz @ 2020-05-05 19:00 UTC (permalink / raw)
  To: ardb, eric.snowberg, mingo, nivedita, tglx, linux-efi, linux-kernel

In allocate_e820(), free the EFI map buffer that has been returned
by efi_get_memory_map(). The returned size of the EFI map buffer
is used to allocate an adequately sized e820ext buffer, if it's
needed. But the contents of that EFI map buffer is not used at all
and the local pointer to it is gone on return from allocate_e820().

Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
---
 drivers/firmware/efi/libstub/x86-stub.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index 05ccb229fb45..4efe3e7a218d 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -623,6 +623,9 @@ static efi_status_t allocate_e820(struct boot_params *params,
 	if (status != EFI_SUCCESS)
 		return status;
 
+	/* Allocated EFI map buf is not used here. Just need its size. */
+	efi_bs_call(free_pool, map);
+
 	nr_desc = buff_size / desc_size;
 
 	if (nr_desc > ARRAY_SIZE(params->e820_table)) {
-- 
2.18.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] efi/libstub/x86: Free EFI map buffer in allocate_e820()
  2020-05-05 19:00 [PATCH] efi/libstub/x86: Free EFI map buffer in allocate_e820() Lenny Szubowicz
@ 2020-05-06  7:23 ` Ard Biesheuvel
  2020-05-07  1:49   ` Lenny Szubowicz
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2020-05-06  7:23 UTC (permalink / raw)
  To: Lenny Szubowicz
  Cc: eric.snowberg, Ingo Molnar, Arvind Sankar, Thomas Gleixner,
	linux-efi, Linux Kernel Mailing List

On Tue, 5 May 2020 at 21:00, Lenny Szubowicz <lszubowi@redhat.com> wrote:
>
> In allocate_e820(), free the EFI map buffer that has been returned
> by efi_get_memory_map(). The returned size of the EFI map buffer
> is used to allocate an adequately sized e820ext buffer, if it's
> needed. But the contents of that EFI map buffer is not used at all
> and the local pointer to it is gone on return from allocate_e820().
>
> Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
> ---
>  drivers/firmware/efi/libstub/x86-stub.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> index 05ccb229fb45..4efe3e7a218d 100644
> --- a/drivers/firmware/efi/libstub/x86-stub.c
> +++ b/drivers/firmware/efi/libstub/x86-stub.c
> @@ -623,6 +623,9 @@ static efi_status_t allocate_e820(struct boot_params *params,
>         if (status != EFI_SUCCESS)
>                 return status;
>
> +       /* Allocated EFI map buf is not used here. Just need its size. */
> +       efi_bs_call(free_pool, map);
> +

Wouldn't it be better to call BS->GetMemoryMap() directly here, with a
zero size for the input buffer?

>         nr_desc = buff_size / desc_size;
>
>         if (nr_desc > ARRAY_SIZE(params->e820_table)) {
> --
> 2.18.4
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] efi/libstub/x86: Free EFI map buffer in allocate_e820()
  2020-05-06  7:23 ` Ard Biesheuvel
@ 2020-05-07  1:49   ` Lenny Szubowicz
  0 siblings, 0 replies; 3+ messages in thread
From: Lenny Szubowicz @ 2020-05-07  1:49 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: eric.snowberg, Ingo Molnar, Arvind Sankar, Thomas Gleixner,
	linux-efi, Linux Kernel Mailing List

On 5/6/20 3:23 AM, Ard Biesheuvel wrote:
> On Tue, 5 May 2020 at 21:00, Lenny Szubowicz <lszubowi@redhat.com> wrote:
>>
>> In allocate_e820(), free the EFI map buffer that has been returned
>> by efi_get_memory_map(). The returned size of the EFI map buffer
>> is used to allocate an adequately sized e820ext buffer, if it's
>> needed. But the contents of that EFI map buffer is not used at all
>> and the local pointer to it is gone on return from allocate_e820().
>>
>> Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
>> ---
>>   drivers/firmware/efi/libstub/x86-stub.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
>> index 05ccb229fb45..4efe3e7a218d 100644
>> --- a/drivers/firmware/efi/libstub/x86-stub.c
>> +++ b/drivers/firmware/efi/libstub/x86-stub.c
>> @@ -623,6 +623,9 @@ static efi_status_t allocate_e820(struct boot_params *params,
>>          if (status != EFI_SUCCESS)
>>                  return status;
>>
>> +       /* Allocated EFI map buf is not used here. Just need its size. */
>> +       efi_bs_call(free_pool, map);
>> +
> 
> Wouldn't it be better to call BS->GetMemoryMap() directly here, with a
> zero size for the input buffer?

I agree, that's a good suggestion. V2 coming shortly after testing.

> 
>>          nr_desc = buff_size / desc_size;
>>
>>          if (nr_desc > ARRAY_SIZE(params->e820_table)) {
>> --
>> 2.18.4
>>
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-07  1:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 19:00 [PATCH] efi/libstub/x86: Free EFI map buffer in allocate_e820() Lenny Szubowicz
2020-05-06  7:23 ` Ard Biesheuvel
2020-05-07  1:49   ` Lenny Szubowicz

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.