mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] ddr: fsl: fix possible use of uninitalized variable
@ 2024-02-19 13:30 Ahmad Fatoum
  2024-02-20  7:17 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-02-19 13:30 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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@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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH master] ddr: fsl: fix possible use of uninitalized variable
  2024-02-19 13:30 [PATCH master] ddr: fsl: fix possible use of uninitalized variable Ahmad Fatoum
@ 2024-02-20  7:17 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-02-20  7:17 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 19 Feb 2024 14:30:59 +0100, Ahmad Fatoum wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] ddr: fsl: fix possible use of uninitalized variable
      https://git.pengutronix.de/cgit/barebox/commit/?id=1d8515a0d3f7 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-20  7:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 13:30 [PATCH master] ddr: fsl: fix possible use of uninitalized variable Ahmad Fatoum
2024-02-20  7:17 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox