Skip to content

Commit 000a335

Browse files
geertugregkh
authored andcommitted
mtd: spi-nor: stm32-quadspi: Fix uninitialized error return code
[ Upstream commit 05521bd ] With gcc 4.1.2: drivers/mtd/spi-nor/stm32-quadspi.c: In function ‘stm32_qspi_tx_poll’: drivers/mtd/spi-nor/stm32-quadspi.c:230: warning: ‘ret’ may be used uninitialized in this function Indeed, if stm32_qspi_cmd.len is zero, ret will be uninitialized. This length is passed from outside the driver using the spi_nor.{read,write}{,_reg}() callbacks. Several functions in drivers/mtd/spi-nor/spi-nor.c (e.g. write_enable(), write_disable(), and erase_chip()) call spi_nor.write_reg() with a zero length. Fix this by returning an explicit zero on success. Fixes: 0d43d7a ("mtd: spi-nor: add driver for STM32 quad spi flash controller") Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Ludovic Barre <ludovic.barre@st.com> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bca4d7e commit 000a335

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/mtd/spi-nor/stm32-quadspi.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ static int stm32_qspi_tx_poll(struct stm32_qspi *qspi,
240240
STM32_QSPI_FIFO_TIMEOUT_US);
241241
if (ret) {
242242
dev_err(qspi->dev, "fifo timeout (stat:%#x)\n", sr);
243-
break;
243+
return ret;
244244
}
245245
tx_fifo(buf++, qspi->io_base + QUADSPI_DR);
246246
}
247247

248-
return ret;
248+
return 0;
249249
}
250250

251251
static int stm32_qspi_tx_mm(struct stm32_qspi *qspi,

0 commit comments

Comments
 (0)