All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: fsmc: Fix unchecked return value in fsmc_read_page_hwecc
@ 2018-10-10 15:58 Gustavo A. R. Silva
  2018-11-11 20:51 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-10 15:58 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, Richard Weinberger,
	David Woodhouse, Brian Norris, Marek Vasut
  Cc: linux-mtd, linux-kernel, Gustavo A. R. Silva

Check return value of nand_read_data_op.

Notice that, currently, all instances of nand_read_data_op() are
being checked, with the exception of two of them in marvell_nand
driver, in which the caller function explicitly returns 0 every
time.

Also, notice that I moved the declaration of *ret* to the top of
fsmc_read_page_hwecc().

Addresses-Coverity-ID: 1471968 ("Unchecked return value")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/mtd/nand/raw/fsmc_nand.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
index 70ac8d8..41ba76e 100644
--- a/drivers/mtd/nand/raw/fsmc_nand.c
+++ b/drivers/mtd/nand/raw/fsmc_nand.c
@@ -727,7 +727,7 @@ static int fsmc_read_page_hwecc(struct nand_chip *chip, uint8_t *buf,
 	uint8_t *p = buf;
 	uint8_t *ecc_calc = chip->ecc.calc_buf;
 	uint8_t *ecc_code = chip->ecc.code_buf;
-	int off, len, group = 0;
+	int off, len, ret, group = 0;
 	/*
 	 * ecc_oob is intentionally taken as uint16_t. In 16bit devices, we
 	 * end up reading 14 bytes (7 words) from oob. The local array is
@@ -740,11 +740,12 @@ static int fsmc_read_page_hwecc(struct nand_chip *chip, uint8_t *buf,
 	for (i = 0, s = 0; s < eccsteps; s++, i += eccbytes, p += eccsize) {
 		nand_read_page_op(chip, page, s * eccsize, NULL, 0);
 		chip->ecc.hwctl(chip, NAND_ECC_READ);
-		nand_read_data_op(chip, p, eccsize, false);
+		ret = nand_read_data_op(chip, p, eccsize, false);
+		if (ret)
+			return ret;
 
 		for (j = 0; j < eccbytes;) {
 			struct mtd_oob_region oobregion;
-			int ret;
 
 			ret = mtd_ooblayout_ecc(mtd, group++, &oobregion);
 			if (ret)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: rawnand: fsmc: Fix unchecked return value in fsmc_read_page_hwecc
  2018-10-10 15:58 [PATCH] mtd: rawnand: fsmc: Fix unchecked return value in fsmc_read_page_hwecc Gustavo A. R. Silva
@ 2018-11-11 20:51 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2018-11-11 20:51 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Boris Brezillon, Richard Weinberger, David Woodhouse,
	Brian Norris, Marek Vasut, linux-mtd, linux-kernel

Hi Gustavo,

"Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote on Wed, 10 Oct
2018 17:58:58 +0200:

> Check return value of nand_read_data_op.
> 
> Notice that, currently, all instances of nand_read_data_op() are
> being checked, with the exception of two of them in marvell_nand
> driver, in which the caller function explicitly returns 0 every
> time.
> 
> Also, notice that I moved the declaration of *ret* to the top of
> fsmc_read_page_hwecc().
> 
> Addresses-Coverity-ID: 1471968 ("Unchecked return value")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---

Applied to nand/next.

Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-11 20:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-10 15:58 [PATCH] mtd: rawnand: fsmc: Fix unchecked return value in fsmc_read_page_hwecc Gustavo A. R. Silva
2018-11-11 20:51 ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.