mtd: spi-nor: Off by one in cqspi_setup_flash()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 13 Oct 2016 08:06:47 +0000 (11:06 +0300)
committerCyrille Pitchen <cyrille.pitchen@atmel.com>
Sat, 26 Nov 2016 15:50:03 +0000 (16:50 +0100)
There are CQSPI_MAX_CHIPSELECT elements in the ->f_pdata array so the >
should be >=.

Fixes: 140623410536 ('mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
drivers/mtd/spi-nor/cadence-quadspi.c

index d403ba7b8f432ea45690767e334b6d6d8f8016bb..944863be0320dfbad9b341705b49356f1c0700ec 100644 (file)
@@ -1082,7 +1082,7 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np)
                        goto err;
                }
 
-               if (cs > CQSPI_MAX_CHIPSELECT) {
+               if (cs >= CQSPI_MAX_CHIPSELECT) {
                        dev_err(dev, "Chip select %d out of range.\n", cs);
                        goto err;
                }