Skip to content

Commit

Permalink
mtd: rawnand: stm32_fmc2: fix a buffer overflow
Browse files Browse the repository at this point in the history
[ Upstream commit ab16f54 ]

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: 2cd457f ("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>
  • Loading branch information
Christophe Kerello authored and gregkh committed Oct 29, 2020
1 parent 86e185a commit fbb2d15
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/nand/raw/stm32_fmc2_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit fbb2d15

Please sign in to comment.