[PATCH] ddr: altera: n5x: Return error if invalid DDR type is detected in argument

Jit Loon Lim jit.loon.lim at intel.com
Wed Nov 23 15:30:33 CET 2022


From: Tien Fong Chee <tien.fong.chee at intel.com>

Return error immediately if invalid DDR type is detected in argument so
that uninitialized local variables such val and upd_val would not be used.

Signed-off-by: Tien Fong Chee <tien.fong.chee at intel.com>
Signed-off-by: Jit Loon Lim <jit.loon.lim at intel.com>
---
 drivers/ddr/altera/sdram_n5x.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/ddr/altera/sdram_n5x.c b/drivers/ddr/altera/sdram_n5x.c
index 5117a5c4cf..8d28cdbc03 100644
--- a/drivers/ddr/altera/sdram_n5x.c
+++ b/drivers/ddr/altera/sdram_n5x.c
@@ -2430,6 +2430,9 @@ static int set_cal_res_to_umctl2(struct ddr_handoff *handoff,
 
 		upd_val = GET_LOWB_DATA(readw((uintptr_t)(handoff->phy_base +
 					DMEM_MB_CDD_CHB_WW_0_1_OFFSET)));
+	} else {
+		debug("%s: Invalid DDR controller type\n", __func__);
+		return -ENXIO;
 	}
 
 	upd_val = max(val, upd_val);
-- 
2.26.2



More information about the U-Boot mailing list