mirror of
https://xff.cz/git/u-boot/
synced 2025-10-18 08:23:24 +02:00
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>
This commit is contained in:
@@ -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 */
|
||||
|
Reference in New Issue
Block a user