Skip to content

Commit bec5f60

Browse files
ytcooderobherring
authored andcommitted
of/fdt: Fix the len check in early_init_dt_check_for_elfcorehdr()
The len value is in bytes, while `dt_root_addr_cells + dt_root_size_cells` is in cells (4 bytes per cell). Comparing them directly is incorrect. Use a helper function to simplify the code and address this issue. Fixes: f7e7ce9 ("of: fdt: Add generic support for handling elf core headers property") Fixes: e62aaea ("arm64: kdump: provide /proc/vmcore file") Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev> Link: https://patch.msgid.link/20251115134753.179931-3-yuntao.wang@linux.dev Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
1 parent 8278cb7 commit bec5f60

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

drivers/of/fdt.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -853,21 +853,15 @@ static void __init early_init_dt_check_for_initrd(unsigned long node)
853853
*/
854854
static void __init early_init_dt_check_for_elfcorehdr(unsigned long node)
855855
{
856-
const __be32 *prop;
857-
int len;
858-
859856
if (!IS_ENABLED(CONFIG_CRASH_DUMP))
860857
return;
861858

862859
pr_debug("Looking for elfcorehdr property... ");
863860

864-
prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len);
865-
if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells)))
861+
if (!of_flat_dt_get_addr_size(node, "linux,elfcorehdr",
862+
&elfcorehdr_addr, &elfcorehdr_size))
866863
return;
867864

868-
elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, &prop);
869-
elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, &prop);
870-
871865
pr_debug("elfcorehdr_start=0x%llx elfcorehdr_size=0x%llx\n",
872866
elfcorehdr_addr, elfcorehdr_size);
873867
}

0 commit comments

Comments
 (0)