2020-02-16 18:41:43

by Heinrich Schuchardt

[permalink] [raw]
Subject: [PATCH 1/1] efi/libstub: simplify efi_get_memory_map()

Do not check the value of status twice.

Signed-off-by: Heinrich Schuchardt <[email protected]>
---
drivers/firmware/efi/libstub/mem.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/efi/libstub/mem.c b/drivers/firmware/efi/libstub/mem.c
index c6a784ed640f..c25fd9174b74 100644
--- a/drivers/firmware/efi/libstub/mem.c
+++ b/drivers/firmware/efi/libstub/mem.c
@@ -52,13 +52,14 @@ efi_status_t efi_get_memory_map(struct efi_boot_memmap *map)
goto again;
}

- if (status != EFI_SUCCESS)
+ if (status == EFI_SUCCESS) {
+ if (map->key_ptr)
+ *map->key_ptr = key;
+ if (map->desc_ver)
+ *map->desc_ver = desc_version;
+ } else {
efi_bs_call(free_pool, m);
-
- if (map->key_ptr && status == EFI_SUCCESS)
- *map->key_ptr = key;
- if (map->desc_ver && status == EFI_SUCCESS)
- *map->desc_ver = desc_version;
+ }

fail:
*map->map = m;
--
2.25.0


2020-02-17 08:38:28

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCH 1/1] efi/libstub: simplify efi_get_memory_map()

On Sun, 16 Feb 2020 at 19:40, Heinrich Schuchardt <[email protected]> wrote:
>
> Do not check the value of status twice.
>
> Signed-off-by: Heinrich Schuchardt <[email protected]>

Thanks, I'll queue this one as well.

> ---
> drivers/firmware/efi/libstub/mem.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/mem.c b/drivers/firmware/efi/libstub/mem.c
> index c6a784ed640f..c25fd9174b74 100644
> --- a/drivers/firmware/efi/libstub/mem.c
> +++ b/drivers/firmware/efi/libstub/mem.c
> @@ -52,13 +52,14 @@ efi_status_t efi_get_memory_map(struct efi_boot_memmap *map)
> goto again;
> }
>
> - if (status != EFI_SUCCESS)
> + if (status == EFI_SUCCESS) {
> + if (map->key_ptr)
> + *map->key_ptr = key;
> + if (map->desc_ver)
> + *map->desc_ver = desc_version;
> + } else {
> efi_bs_call(free_pool, m);
> -
> - if (map->key_ptr && status == EFI_SUCCESS)
> - *map->key_ptr = key;
> - if (map->desc_ver && status == EFI_SUCCESS)
> - *map->desc_ver = desc_version;
> + }
>
> fail:
> *map->map = m;
> --
> 2.25.0
>