diff mbox series

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

Message ID 20221123143033.22416-1-jit.loon.lim@intel.com
State Needs Review / ACK, archived
Delegated to: Marek Vasut
Headers show
Series ddr: altera: n5x: Return error if invalid DDR type is detected in argument | expand

Commit Message

Jit Loon Lim Nov. 23, 2022, 2:30 p.m. UTC
From: Tien Fong Chee <tien.fong.chee@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@intel.com>
Signed-off-by: Jit Loon Lim <jit.loon.lim@intel.com>
---
 drivers/ddr/altera/sdram_n5x.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

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);