[PATCH master] ddr: fsl: fix possible use of uninitalized variable

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Feb 19 05:30:59 PST 2024


step_assign_addresses_interleaved() contains a loop that either sets
total_mem to a fixed value or keeps incrementing it.

If we exclusively run into the "keep incrementing it"-case, we would
start with an uninitialized total_mem. Fix this by initializing it to 0.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/ddr/fsl/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ddr/fsl/main.c b/drivers/ddr/fsl/main.c
index 27303fec7e39..c8217a86ddf8 100644
--- a/drivers/ddr/fsl/main.c
+++ b/drivers/ddr/fsl/main.c
@@ -97,7 +97,7 @@ static unsigned long long step_assign_addresses_linear(struct fsl_ddr_info *pinf
 static unsigned long long step_assign_addresses_interleaved(struct fsl_ddr_info *pinfo,
 							    unsigned long long current_mem_base)
 {
-	unsigned long long total_mem, total_ctlr_mem;
+	unsigned long long total_mem = 0, total_ctlr_mem;
 	unsigned long long rank_density, ctlr_density = 0;
 	int i;
 
-- 
2.39.2




More information about the barebox mailing list