]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
of/fdt: Fix the len check in early_init_dt_check_for_usable_mem_range()
authorYuntao Wang <yuntao.wang@linux.dev>
Sat, 15 Nov 2025 13:47:48 +0000 (21:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:03:07 +0000 (14:03 +0100)
commit38c8c945c2c2b404e7203b36023d2aa0a888c617
tree9669c2d68ac3b362156e3178c62328c09aba5c23
parentf326efdcab7f826ccd3a0a54cd737b7320444f10
of/fdt: Fix the len check in early_init_dt_check_for_usable_mem_range()

[ Upstream commit 463942de13cd30fad5dba709f708483eab7efc2c ]

The len value is in bytes, while `dt_root_addr_cells + dt_root_size_cells`
is in cells (4 bytes per cell). Modulo calculation between them is
incorrect, the units must be converted first.

Use helper functions to simplify the code and fix this issue.

Fixes: fb319e77a0e7 ("of: fdt: Add memory for devices by DT property "linux,usable-memory-range"")
Fixes: 2af2b50acf9b9c38 ("of: fdt: Add generic support for handling usable memory range property")
Fixes: 8f579b1c4e347b23 ("arm64: limit memory regions based on DT property, usable-memory-range")
Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev>
Link: https://patch.msgid.link/20251115134753.179931-4-yuntao.wang@linux.dev
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/of/fdt.c