mtd: rawnand: stm32_fmc2: fix a buffer overflow
authorChristophe Kerello <christophe.kerello@st.com>
Tue, 21 Jul 2020 09:52:07 +0000 (11:52 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 30 Sep 2020 14:44:15 +0000 (16:44 +0200)
This patch solves following static checker warning:
drivers/mtd/nand/raw/stm32_fmc2_nand.c:350 stm32_fmc2_nfc_select_chip()
error: buffer overflow 'nfc->data_phys_addr' 2 <= 2

The CS value can only be 0 or 1.

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Fixes: 2cd457f328c1 ("mtd: rawnand: stm32_fmc2: add STM32 FMC2 NAND flash controller driver")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1595325127-32693-1-git-send-email-christophe.kerello@st.com
drivers/mtd/nand/raw/stm32_fmc2_nand.c

index ba679d2..b31a581 100644 (file)
@@ -1763,7 +1763,7 @@ static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc,
                        return ret;
                }
 
-               if (cs > FMC2_MAX_CE) {
+               if (cs >= FMC2_MAX_CE) {
                        dev_err(nfc->dev, "invalid reg value: %d\n", cs);
                        return -EINVAL;
                }