Skip to content

Commit c85da64

Browse files
ytcooderobherring
authored andcommitted
of/fdt: Fix incorrect use of dt_root_addr_cells in early_init_dt_check_kho()
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: 274cdcb ("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>
1 parent 463942d commit c85da64

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

drivers/of/fdt.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -922,26 +922,18 @@ static void __init early_init_dt_check_kho(void)
922922
{
923923
unsigned long node = chosen_node_offset;
924924
u64 fdt_start, fdt_size, scratch_start, scratch_size;
925-
const __be32 *p;
926-
int l;
927925

928926
if (!IS_ENABLED(CONFIG_KEXEC_HANDOVER) || (long)node < 0)
929927
return;
930928

931-
p = of_get_flat_dt_prop(node, "linux,kho-fdt", &l);
932-
if (l != (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32))
929+
if (!of_flat_dt_get_addr_size(node, "linux,kho-fdt",
930+
&fdt_start, &fdt_size))
933931
return;
934932

935-
fdt_start = dt_mem_next_cell(dt_root_addr_cells, &p);
936-
fdt_size = dt_mem_next_cell(dt_root_addr_cells, &p);
937-
938-
p = of_get_flat_dt_prop(node, "linux,kho-scratch", &l);
939-
if (l != (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32))
933+
if (!of_flat_dt_get_addr_size(node, "linux,kho-scratch",
934+
&scratch_start, &scratch_size))
940935
return;
941936

942-
scratch_start = dt_mem_next_cell(dt_root_addr_cells, &p);
943-
scratch_size = dt_mem_next_cell(dt_root_addr_cells, &p);
944-
945937
kho_populate(fdt_start, fdt_size, scratch_start, scratch_size);
946938
}
947939

0 commit comments

Comments
 (0)