[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240302140335.117769-1-skseofh@gmail.com>
Date: Sat,  2 Mar 2024 23:03:35 +0900
From: skseofh@...il.com
To: robh+dt@...nel.org,
	frowand.list@...il.com
Cc: devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Daero Lee <skseofh@...il.com>
Subject: [PATCH] of: fdt: add size 0 check after page align
From: Daero Lee <skseofh@...il.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@...il.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
Powered by blists - more mailing lists