Skip to content

Commit dcf0c83

Browse files
vlsunilardbiesheuvel
authored andcommitted
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: <[email protected]> Fixes: d707174 ("RISC-V: Add EFI stub support.") Signed-off-by: Sunil V L <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent f5390cd commit dcf0c83

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/firmware/efi/libstub/riscv-stub.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,34 @@ typedef void __noreturn (*jump_kernel_func)(unsigned int, unsigned long);
2525

2626
static u32 hartid;
2727

28-
static u32 get_boot_hartid_from_fdt(void)
28+
static int get_boot_hartid_from_fdt(void)
2929
{
3030
const void *fdt;
3131
int chosen_node, len;
3232
const fdt32_t *prop;
3333

3434
fdt = get_efi_config_table(DEVICE_TREE_GUID);
3535
if (!fdt)
36-
return U32_MAX;
36+
return -EINVAL;
3737

3838
chosen_node = fdt_path_offset(fdt, "/chosen");
3939
if (chosen_node < 0)
40-
return U32_MAX;
40+
return -EINVAL;
4141

4242
prop = fdt_getprop((void *)fdt, chosen_node, "boot-hartid", &len);
4343
if (!prop || len != sizeof(u32))
44-
return U32_MAX;
44+
return -EINVAL;
4545

46-
return fdt32_to_cpu(*prop);
46+
hartid = fdt32_to_cpu(*prop);
47+
return 0;
4748
}
4849

4950
efi_status_t check_platform_features(void)
5051
{
51-
hartid = get_boot_hartid_from_fdt();
52-
if (hartid == U32_MAX) {
52+
int ret;
53+
54+
ret = get_boot_hartid_from_fdt();
55+
if (ret) {
5356
efi_err("/chosen/boot-hartid missing or invalid!\n");
5457
return EFI_UNSUPPORTED;
5558
}

0 commit comments

Comments
 (0)