]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(imx8m): fix dram retention fsp_table access
authorMarco Felsch <m.felsch@pengutronix.de>
Wed, 21 Sep 2022 15:48:35 +0000 (17:48 +0200)
committerMarco Felsch <m.felsch@pengutronix.de>
Thu, 20 Oct 2022 16:16:41 +0000 (18:16 +0200)
The fsp_table access by [i-1] can cause invalid memory access in case of
i=0. This can be the case if no fsp_table is available. Fix this by
adding the idx variable which tracks the correct index.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Change-Id: If2285517eb9fe837f3ad54360307a77a658bf62c

plat/imx/imx8m/ddr/dram.c

index 6ccd6fd178ae7b17866119809ca7c7f28c64121e..8ea9ba192074d4454b4f96ac628c5400da1aa8f5 100644 (file)
@@ -120,6 +120,7 @@ static uint64_t waiting_dvfs(uint32_t id, uint32_t flags,
 void dram_info_init(unsigned long dram_timing_base)
 {
        uint32_t ddrc_mstr, current_fsp;
+       unsigned int idx = 0;
        uint32_t flags = 0;
        uint32_t rc;
        unsigned int i;
@@ -144,11 +145,12 @@ void dram_info_init(unsigned long dram_timing_base)
                if (!dram_info.timing_info->fsp_table[i]) {
                        break;
                }
+               idx = i;
        }
        dram_info.num_fsp = i;
 
        /* check if has bypass mode support */
-       if (dram_info.timing_info->fsp_table[i-1] < 666) {
+       if (dram_info.timing_info->fsp_table[idx] < 666) {
                dram_info.bypass_mode = true;
        } else {
                dram_info.bypass_mode = false;