devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: fdt: add size 0 check after page align
@ 2024-03-02 14:03 skseofh
  2024-03-04 13:26 ` Rob Herring
  0 siblings, 1 reply; 6+ messages in thread
From: skseofh @ 2024-03-02 14:03 UTC (permalink / raw)
  To: robh+dt, frowand.list; +Cc: devicetree, linux-kernel, Daero Lee

From: Daero Lee <skseofh@gmail.com>

After page aligning, the size may become zero. So I added exception
handling code for size 0.

example : 4K page size
    [before page align]
        base = 0x1800
        size = 0x1100

    [after page align]
        size = 0x900
        base = 0x2000

        size &= PAGE_MASK(~0x7FFF) = 0

Signed-off-by: Daero Lee <skseofh@gmail.com>
---
 drivers/of/fdt.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index bf502ba8da95..01156088fbb4 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1232,6 +1232,11 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
 		base = PAGE_ALIGN(base);
 	}
 	size &= PAGE_MASK;
+	if (!size) {
+		pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
+			base, base + size);
+		return;
+	}
 
 	if (base > MAX_MEMBLOCK_ADDR) {
 		pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-04 22:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-02 14:03 [PATCH] of: fdt: add size 0 check after page align skseofh
2024-03-04 13:26 ` Rob Herring
2024-03-04 14:51   ` skseofh
2024-03-04 15:02   ` [PATCH] of: fdt: modify small size memory check skseofh
2024-03-04 17:05     ` Rob Herring
2024-03-04 22:38       ` skseofh

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).