Commit c85da64c authored by Yuntao Wang's avatar Yuntao Wang Committed by Rob Herring (Arm)
Browse files

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: 274cdcb1 ("arm64: add KHO support")
Signed-off-by: default avatarYuntao Wang <yuntao.wang@linux.dev>
Link: https://patch.msgid.link/20251115134753.179931-5-yuntao.wang@linux.dev


Signed-off-by: default avatarRob Herring (Arm) <robh@kernel.org>
parent 463942de
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -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);
}