kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Boris Brezillon <boris.brezillon@collabora.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	linux-mtd@lists.infradead.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] mtd: nand: Fix error handling in nand_prog_page_op
Date: Wed,  3 Mar 2021 09:42:46 +0000	[thread overview]
Message-ID: <20210303094246.5724-1-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

The less than zero comparison with status is always false because status
is a u8. Fix this by using ret as the return check for the call to
chip->legacy.waitfunc() and checking on this and assigning status to ret
if it is OK.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 52f67def97f1 ("mtd: nand: fix error handling in nand_prog_page_op() #1")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/mtd/nand/raw/nand_base.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 0f6babefaed2..4f263c22c80d 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -1462,9 +1462,10 @@ int nand_prog_page_op(struct nand_chip *chip, unsigned int page,
 				     page);
 		chip->legacy.write_buf(chip, buf, len);
 		chip->legacy.cmdfunc(chip, NAND_CMD_PAGEPROG, -1, -1);
-		status = chip->legacy.waitfunc(chip);
-		if (status < 0)
-			return status;
+		ret = chip->legacy.waitfunc(chip);
+		if (ret < 0)
+			return ret;
+		status = ret;
 	}
 
 	if (status & NAND_STATUS_FAIL)
-- 
2.30.0


             reply	other threads:[~2021-03-04  0:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03  9:42 Colin King [this message]
2021-03-03  9:46 ` [PATCH][next] mtd: nand: Fix error handling in nand_prog_page_op Miquel Raynal
2021-03-03 10:27   ` Colin Ian King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210303094246.5724-1-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=boris.brezillon@collabora.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=s.hauer@pengutronix.de \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).