]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:07:59 +0000 (10:07 +0100)
[ Upstream commit ab16f54ef3cdb6bbc06a36f636a89e6db8a6cea3 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/nand/raw/stm32_fmc2_nand.c

index 65c9d17b25a3cf911ebcecc1b2a700c67a178ea8..dce6d7a10a3649887ab40467a47c1c107d9083c9 100644 (file)
@@ -1791,7 +1791,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;
                }