[PATCH v3] efi/memattr: Convert efi_memattr_init() return type to void

Breno Leitao posted 1 patch 4 months ago
drivers/firmware/efi/memattr.c | 7 +++----
include/linux/efi.h            | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
[PATCH v3] efi/memattr: Convert efi_memattr_init() return type to void
Posted by Breno Leitao 4 months ago
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@debian.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
---
Changes in v3:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v2: https://lore.kernel.org/r/20251010-efi_fw_bug-v2-1-61b2915dce76@debian.org

Changes in v2:
- drop the other patches from the previous patchset
- Link to v1: https://lore.kernel.org/r/20250106-efi_fw_bug-v1-0-01a8eb40bfeb@debian.org
---
 drivers/firmware/efi/memattr.c | 7 +++----
 include/linux/efi.h            | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/efi/memattr.c b/drivers/firmware/efi/memattr.c
index c38b1a335590d..e727cc5909cb6 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 a98cc39e7aaa8..0b9eb3d2ff977 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -772,7 +772,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);
 

---
base-commit: 18a7e218cfcdca6666e1f7356533e4c988780b57
change-id: 20250106-efi_fw_bug-2b62e9a41899

Best regards,
--  
Breno Leitao <leitao@debian.org>
Re: [PATCH v3] efi/memattr: Convert efi_memattr_init() return type to void
Posted by Ard Biesheuvel 2 months, 4 weeks ago
On Fri, 10 Oct 2025 at 12:44, Breno Leitao <leitao@debian.org> 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@debian.org>
> Acked-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> Changes in v3:
> - EDITME: describe what is new in this series revision.
> - EDITME: use bulletpoints and terse descriptions.
> - Link to v2: https://lore.kernel.org/r/20251010-efi_fw_bug-v2-1-61b2915dce76@debian.org
>
> Changes in v2:
> - drop the other patches from the previous patchset
> - Link to v1: https://lore.kernel.org/r/20250106-efi_fw_bug-v1-0-01a8eb40bfeb@debian.org
> ---
>  drivers/firmware/efi/memattr.c | 7 +++----
>  include/linux/efi.h            | 2 +-
>  2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/firmware/efi/memattr.c b/drivers/firmware/efi/memattr.c
> index c38b1a335590d..e727cc5909cb6 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 a98cc39e7aaa8..0b9eb3d2ff977 100644
> --- a/include/linux/efi.h
> +++ b/include/linux/efi.h
> @@ -772,7 +772,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);
>

I've queued this up now in efi/next - thanks for your patience.