diff options
| author | Yuntao Wang <yuntao.wang@linux.dev> | 2025-11-15 21:47:47 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-12-18 14:03:07 +0100 |
| commit | f326efdcab7f826ccd3a0a54cd737b7320444f10 (patch) | |
| tree | 6886f0d9266a6b29b28894ce2a4e45ddbaf1abb4 /drivers/of | |
| parent | 7045d5970e16393c1ad3fd1b27c433b6c22c6dee (diff) | |
| download | linux-f326efdcab7f826ccd3a0a54cd737b7320444f10.tar.gz linux-f326efdcab7f826ccd3a0a54cd737b7320444f10.tar.bz2 linux-f326efdcab7f826ccd3a0a54cd737b7320444f10.zip | |
of/fdt: Fix the len check in early_init_dt_check_for_elfcorehdr()
[ Upstream commit bec5f6092bc1328895992ff02b862ba34b45a0b7 ]
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: f7e7ce93aac1 ("of: fdt: Add generic support for handling elf core headers property")
Fixes: e62aaeac426ab1dd ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/of')
| -rw-r--r-- | drivers/of/fdt.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 0c18bdefbbee..b45f60dccd7c 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -853,21 +853,15 @@ static void __init early_init_dt_check_for_initrd(unsigned long node) */ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) { - const __be32 *prop; - int len; - if (!IS_ENABLED(CONFIG_CRASH_DUMP)) return; pr_debug("Looking for elfcorehdr property... "); - prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); - if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) + if (!of_flat_dt_get_addr_size(node, "linux,elfcorehdr", + &elfcorehdr_addr, &elfcorehdr_size)) return; - elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, &prop); - elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, &prop); - pr_debug("elfcorehdr_start=0x%llx elfcorehdr_size=0x%llx\n", elfcorehdr_addr, elfcorehdr_size); } |
