LoongArch: Fix built-in DTB detection
authorJiaxun Yang <jiaxun.yang@flygoat.com>
Mon, 3 Jun 2024 07:45:53 +0000 (15:45 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 3 Jun 2024 07:45:53 +0000 (15:45 +0800)
fdt_check_header(__dtb_start) will always success because kernel
provides a dummy dtb, and by coincidence __dtb_start clashed with
entry of this dummy dtb. The consequence is fdt passed from firmware
will never be taken.

Fix by trying to utilise __dtb_start only when CONFIG_BUILTIN_DTB is
enabled.

Cc: stable@vger.kernel.org
Fixes: 7b937cc243e5 ("of: Create of_root if no dtb provided by firmware")
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kernel/setup.c

index 89ad756aeeed20976e5a0781cd63737c694447e1..3d048f1be1438863831e19817711292558d75149 100644 (file)
@@ -282,7 +282,7 @@ static void __init fdt_setup(void)
                return;
 
        /* Prefer to use built-in dtb, checking its legality first. */
-       if (!fdt_check_header(__dtb_start))
+       if (IS_ENABLED(CONFIG_BUILTIN_DTB) && !fdt_check_header(__dtb_start))
                fdt_pointer = __dtb_start;
        else
                fdt_pointer = efi_fdt_pointer(); /* Fallback to firmware dtb */