From: Christophe Kerello Date: Fri, 31 Jul 2020 07:53:34 +0000 (+0200) Subject: mtd: rawnand: stm32_fmc2: fix a buffer overflow X-Git-Url: http://git.dujemihanovic.xyz/login.html?a=commitdiff_plain;h=e99e812e12909c32b236efb10c16598663236675;p=u-boot.git mtd: rawnand: stm32_fmc2: fix a buffer overflow The chip select defined in the device tree could only be 0 or 1. Signed-off-by: Christophe Kerello Reviewed-by: Patrice Chotard --- diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c index 3306bd8ac9..2929acf66d 100644 --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c @@ -846,7 +846,7 @@ static int stm32_fmc2_parse_child(struct stm32_fmc2_nfc *fmc2, } for (i = 0; i < nand->ncs; i++) { - if (cs[i] > FMC2_MAX_CE) { + if (cs[i] >= FMC2_MAX_CE) { pr_err("Invalid reg value: %d\n", nand->cs_used[i]); return -EINVAL;