]> Gentwo Git Trees - linux/.git/commitdiff
of/fdt: Fix incorrect use of dt_root_addr_cells in early_init_dt_check_kho()
authorYuntao Wang <yuntao.wang@linux.dev>
Sat, 15 Nov 2025 13:47:49 +0000 (21:47 +0800)
committerRob Herring (Arm) <robh@kernel.org>
Thu, 20 Nov 2025 14:32:48 +0000 (08:32 -0600)
When reading the fdt_size value, the argument passed to dt_mem_next_cell()
is dt_root_addr_cells, but it should be dt_root_size_cells.

The same issue occurs when reading the scratch_size value.

Use a helper function to simplify the code and fix these issues.

Fixes: 274cdcb1c004 ("arm64: add KHO support")
Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev>
Link: https://patch.msgid.link/20251115134753.179931-5-yuntao.wang@linux.dev
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/fdt.c

index ea37ba694bcd7396b2cb679f399e0e67cc80cab9..fdaee4906836f9de1bdaa4254c81cbd23b971fdb 100644 (file)
@@ -922,26 +922,18 @@ static void __init early_init_dt_check_kho(void)
 {
        unsigned long node = chosen_node_offset;
        u64 fdt_start, fdt_size, scratch_start, scratch_size;
-       const __be32 *p;
-       int l;
 
        if (!IS_ENABLED(CONFIG_KEXEC_HANDOVER) || (long)node < 0)
                return;
 
-       p = of_get_flat_dt_prop(node, "linux,kho-fdt", &l);
-       if (l != (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32))
+       if (!of_flat_dt_get_addr_size(node, "linux,kho-fdt",
+                                     &fdt_start, &fdt_size))
                return;
 
-       fdt_start = dt_mem_next_cell(dt_root_addr_cells, &p);
-       fdt_size = dt_mem_next_cell(dt_root_addr_cells, &p);
-
-       p = of_get_flat_dt_prop(node, "linux,kho-scratch", &l);
-       if (l != (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32))
+       if (!of_flat_dt_get_addr_size(node, "linux,kho-scratch",
+                                     &scratch_start, &scratch_size))
                return;
 
-       scratch_start = dt_mem_next_cell(dt_root_addr_cells, &p);
-       scratch_size = dt_mem_next_cell(dt_root_addr_cells, &p);
-
        kho_populate(fdt_start, fdt_size, scratch_start, scratch_size);
 }