summaryrefslogtreecommitdiff
path: root/drivers/ddr/fsl/main.c
diff options
context:
space:
mode:
authorYork Sun <yorksun@freescale.com>2014-04-01 14:20:49 -0700
committerYork Sun <yorksun@freescale.com>2014-04-22 17:58:49 -0700
commit349689b8021f0a7d7923099bd8bbe5eab117d4fa (patch)
treeeafb5be0e0ad33d739baa1ed885a7cdc9f412561 /drivers/ddr/fsl/main.c
parent2ee6c52e229e1d0d1e78c3efbc67bc8bb868fb25 (diff)
downloadu-boot-imx-349689b8021f0a7d7923099bd8bbe5eab117d4fa.zip
u-boot-imx-349689b8021f0a7d7923099bd8bbe5eab117d4fa.tar.gz
u-boot-imx-349689b8021f0a7d7923099bd8bbe5eab117d4fa.tar.bz2
drivers/ddr: Fix possible out of bounds error
This is a theoretical possible out of bounds error in DDR driver. Adding check before using array index. Also change some runtime conditions to pre-compiling conditions. Signed-off-by: York Sun <yorksun@freescale.com> Reviewed-by: York Sun <yorksun@freescale.com>
Diffstat (limited to 'drivers/ddr/fsl/main.c')
-rw-r--r--drivers/ddr/fsl/main.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/ddr/fsl/main.c b/drivers/ddr/fsl/main.c
index f95704f..5e001fc 100644
--- a/drivers/ddr/fsl/main.c
+++ b/drivers/ddr/fsl/main.c
@@ -220,6 +220,11 @@ const char * step_to_string(unsigned int step) {
if ((1 << s) != step)
return step_string_tbl[7];
+ if (s >= ARRAY_SIZE(step_string_tbl)) {
+ printf("Error for the step in %s\n", __func__);
+ s = 0;
+ }
+
return step_string_tbl[s];
}
@@ -520,6 +525,7 @@ fsl_ddr_compute(fsl_ddr_info_t *pinfo, unsigned int start_step,
/* STEP 5: Assign addresses to chip selects */
check_interleaving_options(pinfo);
total_mem = step_assign_addresses(pinfo, dbw_capacity_adjust);
+ debug("Total mem %llu assigned\n", total_mem);
case STEP_COMPUTE_REGS:
/* STEP 6: compute controller register values */