* [PATCH] of: fdt: Fix the len check in early_init_dt_check_for_usable_mem_range()
@ 2025-11-02 14:14 Yuntao Wang
0 siblings, 0 replies; only message in thread
From: Yuntao Wang @ 2025-11-02 14:14 UTC (permalink / raw)
To: linux-kernel, devicetree
Cc: Rob Herring, Saravana Kannan, Catalin Marinas, Baoquan He,
Zhen Lei, Chen Zhou, Yuntao Wang
The len value is in bytes, while `dt_root_addr_cells + dt_root_size_cells`
is in cells (4 bytes per cell).
The modulo calculation between them is incorrect, the units must be
converted first.
Fixes: fb319e77a0e7 ("of: fdt: Add memory for devices by DT property "linux,usable-memory-range"")
Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev>
---
drivers/of/fdt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 0edd639898a6..21ddc28a1257 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -852,6 +852,7 @@ void __init early_init_dt_check_for_usable_mem_range(void)
const __be32 *prop, *endp;
int len, i;
unsigned long node = chosen_node_offset;
+ int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32);
if ((long)node < 0)
return;
@@ -859,7 +860,7 @@ void __init early_init_dt_check_for_usable_mem_range(void)
pr_debug("Looking for usable-memory-range property... ");
prop = of_get_flat_dt_prop(node, "linux,usable-memory-range", &len);
- if (!prop || (len % (dt_root_addr_cells + dt_root_size_cells)))
+ if (!prop || len % t_len)
return;
endp = prop + (len / sizeof(__be32));
--
2.51.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-11-02 14:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-02 14:14 [PATCH] of: fdt: Fix the len check in early_init_dt_check_for_usable_mem_range() Yuntao Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).