Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Changbin Du <changbin.du@gmail.com>
Fixes: b91540d52a08b ("RISC-V: Add EFI runtime services")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

authored by

Changbin Du and committed by
Ard Biesheuvel
668a84c1 6efb943b

+3
+3
drivers/firmware/efi/fdtparams.c
··· 98 98 BUILD_BUG_ON(ARRAY_SIZE(target) != ARRAY_SIZE(name)); 99 99 BUILD_BUG_ON(ARRAY_SIZE(target) != ARRAY_SIZE(dt_params[0].params)); 100 100 101 + if (!fdt) 102 + return 0; 103 + 101 104 for (i = 0; i < ARRAY_SIZE(dt_params); i++) { 102 105 node = fdt_path_offset(fdt, dt_params[i].path); 103 106 if (node < 0)