Commit dcf0c838 authored by Sunil V L's avatar Sunil V L Committed by Ard Biesheuvel

riscv/efi_stub: Fix get_boot_hartid_from_fdt() return value

The get_boot_hartid_from_fdt() function currently returns U32_MAX
for failure case which is not correct because U32_MAX is a valid
hartid value. This patch fixes the issue by returning error code.

Cc: <stable@vger.kernel.org>
Fixes: d7071743 ("RISC-V: Add EFI stub support.")
Signed-off-by: default avatarSunil V L <sunilvl@ventanamicro.com>
Reviewed-by: default avatarHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent f5390cd0
...@@ -25,7 +25,7 @@ typedef void __noreturn (*jump_kernel_func)(unsigned int, unsigned long); ...@@ -25,7 +25,7 @@ typedef void __noreturn (*jump_kernel_func)(unsigned int, unsigned long);
static u32 hartid; static u32 hartid;
static u32 get_boot_hartid_from_fdt(void) static int get_boot_hartid_from_fdt(void)
{ {
const void *fdt; const void *fdt;
int chosen_node, len; int chosen_node, len;
...@@ -33,23 +33,26 @@ static u32 get_boot_hartid_from_fdt(void) ...@@ -33,23 +33,26 @@ static u32 get_boot_hartid_from_fdt(void)
fdt = get_efi_config_table(DEVICE_TREE_GUID); fdt = get_efi_config_table(DEVICE_TREE_GUID);
if (!fdt) if (!fdt)
return U32_MAX; return -EINVAL;
chosen_node = fdt_path_offset(fdt, "/chosen"); chosen_node = fdt_path_offset(fdt, "/chosen");
if (chosen_node < 0) if (chosen_node < 0)
return U32_MAX; return -EINVAL;
prop = fdt_getprop((void *)fdt, chosen_node, "boot-hartid", &len); prop = fdt_getprop((void *)fdt, chosen_node, "boot-hartid", &len);
if (!prop || len != sizeof(u32)) if (!prop || len != sizeof(u32))
return U32_MAX; return -EINVAL;
return fdt32_to_cpu(*prop); hartid = fdt32_to_cpu(*prop);
return 0;
} }
efi_status_t check_platform_features(void) efi_status_t check_platform_features(void)
{ {
hartid = get_boot_hartid_from_fdt(); int ret;
if (hartid == U32_MAX) {
ret = get_boot_hartid_from_fdt();
if (ret) {
efi_err("/chosen/boot-hartid missing or invalid!\n"); efi_err("/chosen/boot-hartid missing or invalid!\n");
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment