Skip to contentSkip to conversation

efi/fdt: fix panic when no valid fdt found

PATCH In review Changbin Du 2 participants 2 messages Mar 24, 2021 – Mar 26, 2021 EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi/fdt: fix panic when no valid fdt found

setup_arch() would invoke efi_init()->efi_get_fdt_params(). If no valid fdt found then initial_boot_params will be null. So we should stop further fdt processing here. I encountered this issue on risc-v.

---
 drivers/firmware/efi/fdtparams.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/firmware/efi/fdtparams.c +3 -0
index bb042ab7c2be..e901f8564ca0 100644
@@ -98,6 +98,9 @@ u64 __init efi_get_fdt_params(struct efi_memory_map_data *mm)
 	BUILD_BUG_ON(ARRAY_SIZE(target) != ARRAY_SIZE(name));
 	BUILD_BUG_ON(ARRAY_SIZE(target) != ARRAY_SIZE(dt_params[0].params));
 
+	if (!fdt)
+		return 0;
+
 	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
 		node = fdt_path_offset(fdt, dt_params[i].path);
 		if (node < 0)
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 7 lines · Changbin Du

setup_arch() would invoke efi_init()->efi_get_fdt_params(). If no valid fdt found then initial_boot_params will be null. So we should stop further fdt processing here. I encountered this issue on risc-v.

I'll queue this up, thanks.

Quoted 21 lines
---
 drivers/firmware/efi/fdtparams.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/firmware/efi/fdtparams.c +3 -1
index bb042ab7c2be..e901f8564ca0 100644
@@ -98,6 +98,9 @@ u64 __init efi_get_fdt_params(struct efi_memory_map_data *mm)
        BUILD_BUG_ON(ARRAY_SIZE(target) != ARRAY_SIZE(name));
        BUILD_BUG_ON(ARRAY_SIZE(target) != ARRAY_SIZE(dt_params[0].params));
 
+       if (!fdt)
+               return 0;
+
        for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
                node = fdt_path_offset(fdt, dt_params[i].path);
                if (node < 0)
--

2.30.2