Patchwork efi: Check the number of EFI configuration tables entries

login
register
mail settings
Submitter Rob Bradford
Date April 4, 2019, 11:22 a.m.
Message ID <20190404112256.22494-1-robert.bradford@intel.com>
Download mbox | patch
Permalink /patch/765705/
State New
Headers show

Comments

Rob Bradford - April 4, 2019, 11:22 a.m.
Only try and access the EFI configuration tables if there there are any
reported. This allows EFI to be continued to used on systems where there
are no configuration table entries.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
---
 arch/x86/platform/efi/quirks.c | 3 +++
 drivers/firmware/efi/efi.c     | 3 +++
 2 files changed, 6 insertions(+)
Ard Biesheuvel - April 4, 2019, 1:08 p.m.
On Thu, 4 Apr 2019 at 18:24, Rob Bradford <robert.bradford@intel.com> wrote:
>
> Only try and access the EFI configuration tables if there there are any
> reported. This allows EFI to be continued to used on systems where there
> are no configuration table entries.
>
> Signed-off-by: Rob Bradford <robert.bradford@intel.com>
> ---
>  arch/x86/platform/efi/quirks.c | 3 +++
>  drivers/firmware/efi/efi.c     | 3 +++
>  2 files changed, 6 insertions(+)
>
> diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
> index 95e77a667ba5..a6d0e6afee8f 100644
> --- a/arch/x86/platform/efi/quirks.c
> +++ b/arch/x86/platform/efi/quirks.c
> @@ -486,6 +486,9 @@ int __init efi_reuse_config(u64 tables, int nr_tables)
>         if (!data->smbios)
>                 goto out_memremap;
>
> +       if (nr_tables == 0)
> +               goto out_memremap;
> +

So what is the point of executing the function all the way up to this
point? Can't we just return immediately at the beginning?

>         sz = sizeof(efi_config_table_64_t);
>
>         p = tablep = early_memremap(tables, nr_tables * sz);
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 415849bab233..185424a8b879 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -628,6 +628,9 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)
>         void *config_tables;
>         int sz, ret;
>
> +       if (efi.systab->nr_tables == 0)
> +               return 0;
> +
>         if (efi_enabled(EFI_64BIT))
>                 sz = sizeof(efi_config_table_64_t);
>         else
> --
> 2.20.1
>

Patch

diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 95e77a667ba5..a6d0e6afee8f 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -486,6 +486,9 @@  int __init efi_reuse_config(u64 tables, int nr_tables)
 	if (!data->smbios)
 		goto out_memremap;
 
+	if (nr_tables == 0)
+		goto out_memremap;
+
 	sz = sizeof(efi_config_table_64_t);
 
 	p = tablep = early_memremap(tables, nr_tables * sz);
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 415849bab233..185424a8b879 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -628,6 +628,9 @@  int __init efi_config_init(efi_config_table_type_t *arch_tables)
 	void *config_tables;
 	int sz, ret;
 
+	if (efi.systab->nr_tables == 0)
+		return 0;
+
 	if (efi_enabled(EFI_64BIT))
 		sz = sizeof(efi_config_table_64_t);
 	else