Skip to contentSkip to conversation

arm64: versal2: Initialize num_banks variable in dram_init()

PATCH Applied Pranav Tilak 2 participants 2 messages Aug 20 – Aug 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: versal2: Initialize num_banks variable in dram_init()

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")
---
 board/amd/versal2/board.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/amd/versal2/board.c +2 -1
index 15b79bbea69..ef6eb1af482 100644
@@ -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;
Signature · 1 line
2.43.0
Applied
#1 lore raw
Quoted 15 lines · Pranav Tilak

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")
---
  board/amd/versal2/board.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
board/amd/versal2/board.c +0 -0
index 15b79bbea69..ef6eb1af482 100644

board/amd/versal2/board.c int dram_init(void) · line 269

Quoted 9 lines
board/amd/versal2/board.c +2 -1
@@ -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;

Applied.
M