This test is off by one because the > should be >= and it's also testing against the wrong limit. The MAX_CE_NUM is the maximum size that meson_chip->sels[] is allowed to be but meson_chip->nsels is the actual size. Fixes: 2d570b34b41a ("mtd: rawnand: meson: add support for Amlogic NAND flash controller ") Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> --- drivers/mtd/nand/raw/meson_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index e858d58d97b0..94c90be7e1e0 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -225,7 +225,7 @@ static void meson_nfc_select_chip(struct nand_chip *nand, int chip) struct meson_nfc *nfc = nand_get_controller_data(nand); int ret, value; - if (chip < 0 || WARN_ON_ONCE(chip > MAX_CE_NUM)) + if (chip < 0 || WARN_ON_ONCE(chip >= meson_chip->nsels)) return; nfc->param.chip_select = meson_chip->sels[chip] ? NAND_CE1 : NAND_CE0; -- 2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/