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

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Dec 16 11:59:14 PST 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=10ad1d754a434c024ce7eeb1cec9f69fd3ecc863
Commit:     10ad1d754a434c024ce7eeb1cec9f69fd3ecc863
Parent:     193e87143c290ec16838f5368adc0e0bc94eb931
Author:     Dan Carpenter <dan.carpenter at oracle.com>
AuthorDate: Thu Oct 13 11:30:39 2016 +0300
Committer:  Cyrille Pitchen <cyrille.pitchen at atmel.com>
CommitDate: Sat Nov 26 16:50:13 2016 +0100

    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")
    Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
    Reviewed-by: Marek Vasut <marex at denx.de>
    Reviewed-by: Moritz Fischer <moritz.fischer at ettus.com>
    Signed-off-by: Cyrille Pitchen <cyrille.pitchen at atmel.com>
---
 drivers/mtd/spi-nor/cadence-quadspi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c
index 944863b..d489fbd 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -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;
 		}



More information about the linux-mtd-cvs mailing list