]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
drivers: stm32_fmc2_nand: fix boundary check for chip select
authorLionel Debieve <lionel.debieve@st.com>
Tue, 21 Jul 2020 13:22:55 +0000 (15:22 +0200)
committerLionel Debieve <lionel.debieve@st.com>
Mon, 12 Oct 2020 12:46:31 +0000 (14:46 +0200)
Chip select is retrieved from device tree and check
must be done regarding the MAX_CS defined.

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Reviewed-by: Christophe KERELLO <christophe.kerello@st.com>
Change-Id: I03144b133bd51a845a4794f0f6bbd9402fc04936

drivers/st/fmc/stm32_fmc2_nand.c

index 857743666ea59342f2c08bd46bdd521d98e44a4f..a58a243ad6e5c2999278c76c3be04cfa80cf6588 100644 (file)
@@ -908,7 +908,12 @@ int stm32_fmc2_init(void)
                        WARN("Chip select not well defined\n");
                        return -FDT_ERR_BADVALUE;
                }
+
                stm32_fmc2.cs_sel = fdt32_to_cpu(*cuint);
+               if (stm32_fmc2.cs_sel >= MAX_CS) {
+                       return -FDT_ERR_BADVALUE;
+               }
+
                VERBOSE("NAND CS %i\n", stm32_fmc2.cs_sel);
        }