[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251112143520.233870-8-yuntao.wang@linux.dev>
Date: Wed, 12 Nov 2025 22:35:17 +0800
From: Yuntao Wang <yuntao.wang@...ux.dev>
To: Rob Herring <robh@...nel.org>,
Saravana Kannan <saravanak@...gle.com>
Cc: Geert Uytterhoeven <geert+renesas@...der.be>,
Catalin Marinas <catalin.marinas@....com>,
AKASHI Takahiro <takahiro.akashi@...aro.org>,
James Morse <james.morse@....com>,
Chen Zhou <chenzhou10@...wei.com>,
Baoquan He <bhe@...hat.com>,
Zhen Lei <thunder.leizhen@...wei.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Changyuan Lyu <changyuanl@...gle.com>,
Alexander Graf <graf@...zon.com>,
"Mike Rapoport (Microsoft)" <rppt@...nel.org>,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
Yuntao Wang <yuntao.wang@...ux.dev>
Subject: [PATCH 07/10] of/fdt: Fix the len check in early_init_dt_check_for_usable_mem_range()
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@...ux.dev>
---
drivers/of/fdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 716ebe8c23d3..0f95f3b356ea 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -859,7 +859,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 % dt_root_addr_size_bytes())
return;
endp = prop + (len / sizeof(__be32));
--
2.51.0
Powered by blists - more mailing lists