Re: [PATCH 1/3] efi/memattr: Convert efi_memattr_init() return type to void

From: Ard Biesheuvel
Date: Mon Jan 06 2025 - 14:24:57 EST


Hello Breno,

On Mon, 6 Jan 2025 at 20:03, Breno Leitao <leitao@xxxxxxxxxx> wrote:
>
> The efi_memattr_init() function's return values (0 and -ENOMEM) are never
> checked by callers. Convert the function to return void since the return
> status is unused.
>
> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
> ---
> drivers/firmware/efi/memattr.c | 7 +++----
> include/linux/efi.h | 2 +-
> 2 files changed, 4 insertions(+), 5 deletions(-)
>

Acked-by: Ard Biesheuvel <ardb@xxxxxxxxxx>

> diff --git a/drivers/firmware/efi/memattr.c b/drivers/firmware/efi/memattr.c
> index c38b1a335590d4f6b75012414a936e66f22dcd9a..e727cc5909cb676c47d787ab0d7754b6fdcb493d 100644
> --- a/drivers/firmware/efi/memattr.c
> +++ b/drivers/firmware/efi/memattr.c
> @@ -19,19 +19,19 @@ unsigned long __ro_after_init efi_mem_attr_table = EFI_INVALID_TABLE_ADDR;
> * Reserve the memory associated with the Memory Attributes configuration
> * table, if it exists.
> */
> -int __init efi_memattr_init(void)
> +void __init efi_memattr_init(void)
> {
> efi_memory_attributes_table_t *tbl;
> unsigned long size;
>
> if (efi_mem_attr_table == EFI_INVALID_TABLE_ADDR)
> - return 0;
> + return;
>
> tbl = early_memremap(efi_mem_attr_table, sizeof(*tbl));
> if (!tbl) {
> pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n",
> efi_mem_attr_table);
> - return -ENOMEM;
> + return;
> }
>
> if (tbl->version > 2) {
> @@ -61,7 +61,6 @@ int __init efi_memattr_init(void)
>
> unmap:
> early_memunmap(tbl, sizeof(*tbl));
> - return 0;
> }
>
> /*
> diff --git a/include/linux/efi.h b/include/linux/efi.h
> index e5815867aba971a64091bf0ea017d95f21115124..5404939df81bdc870f6ee5d0fb7cbb53394a2304 100644
> --- a/include/linux/efi.h
> +++ b/include/linux/efi.h
> @@ -771,7 +771,7 @@ extern unsigned long efi_mem_attr_table;
> */
> typedef int (*efi_memattr_perm_setter)(struct mm_struct *, efi_memory_desc_t *, bool);
>
> -extern int efi_memattr_init(void);
> +extern void efi_memattr_init(void);
> extern int efi_memattr_apply_permissions(struct mm_struct *mm,
> efi_memattr_perm_setter fn);
>
>
> --
> 2.43.5
>
>