Skip to contentSkip to conversation

mtd: spi-nor: Fix some error codes in cqspi_setup_flash()

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

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

PATCH 2/2 mtd: spi-nor: Fix some error codes in cqspi_setup_flash()

We return success or possibly uninitialized values on these error paths instead of proper error codes.

Fixes 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller")
drivers/mtd/spi-nor/cadence-quadspi.c +3 -1
index 944863b..d489fbd 100644
@@ -1077,12 +1077,14 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np)
 
 	/* Get flash device data */
 	for_each_available_child_of_node(dev->of_node, np) {
-		if (of_property_read_u32(np, "reg", &cs)) {
+		ret = of_property_read_u32(np, "reg", &cs);
+		if (ret) {
 			dev_err(dev, "Couldn't determine chip select.\n");
 			goto err;
 		}
 
 		if (cs >= CQSPI_MAX_CHIPSELECT) {
+			ret = -EINVAL;
 			dev_err(dev, "Chip select %d out of range.\n", cs);
 			goto err;
 		}
Reviewed-by on v1 2/2
#1 lore raw
Quoted 6 lines · Dan Carpenter

We return success or possibly uninitialized values on these error paths instead of proper error codes.

Fixes 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller")

Nice

Quoted 21 lines
drivers/mtd/spi-nor/cadence-quadspi.c +3 -1
index 944863b..d489fbd 100644
@@ -1077,12 +1077,14 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np)
 
 	/* Get flash device data */
 	for_each_available_child_of_node(dev->of_node, np) {
-		if (of_property_read_u32(np, "reg", &cs)) {
+		ret = of_property_read_u32(np, "reg", &cs);
+		if (ret) {
 			dev_err(dev, "Couldn't determine chip select.\n");
 			goto err;
 		}
 
 		if (cs >= CQSPI_MAX_CHIPSELECT) {
+			ret = -EINVAL;
 			dev_err(dev, "Chip select %d out of range.\n", cs);
 			goto err;
 		}
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw
Quoted 5 lines · Moritz Fischer
Quoted 4 lines · Marek Vasut
Quoted 3 lines · Dan Carpenter

We return success or possibly uninitialized values on these error paths instead of proper error codes.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Fixes 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller")

Nice

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

Thanks!

Quoted 9 lines

Thanks,

Moritz

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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