summaryrefslogtreecommitdiff
path: root/drivers/ddr
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-04-29 08:40:14 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-04-29 09:17:19 +0200
commite75b084a61355788ffb1d6942ad84d1f449d1128 (patch)
tree8f10ccef5f6ab68902a4edaf2c52bf79303fcacb /drivers/ddr
parent4bed1f2fc1b7b41966a1a6a7e18bce6854798547 (diff)
downloadbarebox-e75b084a61355788ffb1d6942ad84d1f449d1128.tar.gz
ddr: fsl: fix null pointer dereference handling DDR4 memories
cppcheck reports: drivers/ddr/fsl/util.c:42:27: error: Null pointer dereference: c [ctunullpointer] unsigned int data_rate = c->ddr_freq; ^ drivers/ddr/fsl/ctrl_regs.c:1114:55: note: Calling function get_memory_clk_period_ps, 1st argument is null const unsigned int mclk_ps = get_memory_clk_period_ps(0); Because get_memory_clk_period_ps expects a valid pointer, but is instead passed NULL. Fix this by passing along the DDR controller handle like all other calls to the function do. This is untested. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/ddr')
-rw-r--r--drivers/ddr/fsl/ctrl_regs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/ddr/fsl/ctrl_regs.c b/drivers/ddr/fsl/ctrl_regs.c
index 4957320d60..eb99e0ea21 100644
--- a/drivers/ddr/fsl/ctrl_regs.c
+++ b/drivers/ddr/fsl/ctrl_regs.c
@@ -1111,7 +1111,7 @@ static void set_ddr_sdram_mode_9(struct fsl_ddr_controller *c,
unsigned short esdmode5; /* Extended SDRAM mode 5 */
int rtt_park = 0;
bool four_cs = false;
- const unsigned int mclk_ps = get_memory_clk_period_ps(0);
+ const unsigned int mclk_ps = get_memory_clk_period_ps(c);
if ((ddr->cs[0].config & SDRAM_CS_CONFIG_EN) &&
(ddr->cs[1].config & SDRAM_CS_CONFIG_EN) &&