Skip to contentSkip to conversation

target/arm: Initialize ARMMMUFaultInfo in v7m_stack_read/write

PATCH In review Peter Maydell 2 participants 2 messages Oct 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Initialize ARMMMUFaultInfo in v7m_stack_read/write

The get_phys_addr() functions take a pointer to an ARMMMUFaultInfo struct, which they fill in only if a fault occurs. This means that the caller must always zero-initialize the struct before passing it in. We forgot to do this in v7m_stack_read() and v7m_stack_write(). Correct the error.

---
Noticed this in passing while I was working in the file on an entirely different issue.

 target/arm/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/helper.c +2 -2
index c83f7c1109c..e3368e7edc5 100644
@@ -6469,7 +6469,7 @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
     target_ulong page_size;
     hwaddr physaddr;
     int prot;
-    ARMMMUFaultInfo fi;
+    ARMMMUFaultInfo fi = {};
     bool secure = mmu_idx & ARM_MMU_IDX_M_S;
     int exc;
     bool exc_secure;
@@ -6531,7 +6531,7 @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr,
     target_ulong page_size;
     hwaddr physaddr;
     int prot;
-    ARMMMUFaultInfo fi;
+    ARMMMUFaultInfo fi = {};
     bool secure = mmu_idx & ARM_MMU_IDX_M_S;
     int exc;
     bool exc_secure;
Signature · 1 line
2.19.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Peter Maydell

The get_phys_addr() functions take a pointer to an ARMMMUFaultInfo struct, which they fill in only if a fault occurs. This means that the caller must always zero-initialize the struct before passing it in. We forgot to do this in v7m_stack_read() and v7m_stack_write(). Correct the error.

Quoted 7 lines

---
Noticed this in passing while I was working in the file on an entirely different issue.

 target/arm/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

r~