In dram_init() num_banks is incremented for every detected DRAM bank
and passed to mem_map_fill() without being initialized, which can add
invalid entries to versal2_mem_map[], so initialize it to zero.

Fixes: 3aebac5a759b ("arm64: versal2: Populate DRAM banks before page table 
size calculation")
Signed-off-by: Pranav Tilak <[email protected]>
---
 board/amd/versal2/board.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/board/amd/versal2/board.c b/board/amd/versal2/board.c
index 15b79bbea69..ef6eb1af482 100644
--- a/board/amd/versal2/board.c
+++ b/board/amd/versal2/board.c
@@ -262,7 +262,8 @@ int dram_init(void)
        ofnode mem = ofnode_null();
        struct resource res;
        int ret, i, reg = 0;
-       u32 num_banks, reloc_use = 0;
+       u32 num_banks = 0;
+       u32 reloc_use = 0;
        u64 text = (u64)_start;
 
        gd->ram_base = (unsigned long)~0;
-- 
2.43.0

Reply via email to