From patchwork Sat Jul 11 22:05:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 241381 List-Id: U-Boot discussion From: xypron.glpk at gmx.de (Heinrich Schuchardt) Date: Sun, 12 Jul 2020 00:05:39 +0200 Subject: [PATCH v4 12/17] efi_loader: optional pointer for ConvertPointer In-Reply-To: <20200711220544.120976-1-xypron.glpk@gmx.de> References: <20200711220544.120976-1-xypron.glpk@gmx.de> Message-ID: <20200711220544.120976-13-xypron.glpk@gmx.de> If the EFI_OPTIONAL_PTR is set in DebugDisposition, a NULL pointer does not constitute an invalid parameter. Signed-off-by: Heinrich Schuchardt --- include/efi_api.h | 2 ++ lib/efi_loader/efi_runtime.c | 6 ++++++ 2 files changed, 8 insertions(+) -- 2.27.0 diff --git a/include/efi_api.h b/include/efi_api.h index 759d911875..5744f6aed8 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -251,6 +251,8 @@ struct efi_rt_properties_table { u32 runtime_services_supported; }; +#define EFI_OPTIONAL_PTR 0x00000001 + struct efi_runtime_services { struct efi_table_hdr hdr; efi_status_t (EFIAPI *get_time)(struct efi_time *time, diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 45baa2fd3e..a4aa1d8b6c 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -512,6 +512,12 @@ efi_convert_pointer(efi_uintn_t debug_disposition, void **address) ret = EFI_INVALID_PARAMETER; goto out; } + if (!*address) { + if (debug_disposition & EFI_OPTIONAL_PTR) + return EFI_SUCCESS; + else + return EFI_INVALID_PARAMETER; + } addr = (uintptr_t)*address; for (i = 0; i < efi_descriptor_count; i++) {