[4.9,114/130] mtd: spi-nor: Fix some error codes in cqspi_setup_flash()
diff mbox series

Message ID 20170124075539.596168300@linuxfoundation.org
State New, archived
Headers show
  • 4.9.6-stable review
Related show

Commit Message

Greg Kroah-Hartman Jan. 24, 2017, 7:55 a.m. UTC
4.9-stable review patch.  If anyone has any objections, please let me know.


From: Dan Carpenter <dan.carpenter@oracle.com>

commit 10ad1d754a434c024ce7eeb1cec9f69fd3ecc863 upstream.

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@oracle.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Moritz Fischer <moritz.fischer@ettus.com>
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 drivers/mtd/spi-nor/cadence-quadspi.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff mbox series

--- 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 cqsp
 	/* 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;