Skip to contentSkip to conversation

mtd: spi-nor: Off by one in cqspi_setup_flash()

PATCH Applied Dan Carpenter 3 participants 3 messages Oct 13, 2016 – Nov 28, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mtd: spi-nor: Off by one in cqspi_setup_flash()

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')
drivers/mtd/spi-nor/cadence-quadspi.c +1 -1
index d403ba7..944863b 100644
@@ -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;
 		}
Reviewed-by on v1 1/2
#1 lore raw
Quoted 5 lines · Dan Carpenter

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')
Quoted 14 lines
drivers/mtd/spi-nor/cadence-quadspi.c +1 -1
index d403ba7..944863b 100644
@@ -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;
 		}
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Dan Carpenter

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')

Applied to git://github.com/spi-nor/linux.git

Thanks!

Quoted 9 lines
Quoted 9 lines
drivers/mtd/spi-nor/cadence-quadspi.c +0 -0
index d403ba7..944863b 100644
@@ -1082,7 +1082,7 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np)
 			goto err;
 		}
 
Quoted 8 lines

drivers/mtd/spi-nor/cadence-quadspi.c static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np) · line 1088

Quoted 6 lines
drivers/mtd/spi-nor/cadence-quadspi.c +1 -1
-		if (cs > CQSPI_MAX_CHIPSELECT) {
+		if (cs >= CQSPI_MAX_CHIPSELECT) {
 			dev_err(dev, "Chip select %d out of range.\n", cs);
 			goto err;
 		}

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html