[PATCH][next] mtd: nand: Fix error handling in nand_prog_page_op

From: Colin King
Date: Wed Mar 03 2021 - 10:19:59 EST


From: Colin Ian King <colin.king@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxx>
---
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