* [PATCH][next] mtd: nand: Fix error handling in nand_prog_page_op
@ 2021-03-03 9:42 Colin King
2021-03-03 9:46 ` Miquel Raynal
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2021-03-03 9:42 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
Boris Brezillon, Sascha Hauer, linux-mtd
Cc: kernel-janitors, linux-kernel
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] mtd: nand: Fix error handling in nand_prog_page_op
2021-03-03 9:42 [PATCH][next] mtd: nand: Fix error handling in nand_prog_page_op Colin King
@ 2021-03-03 9:46 ` Miquel Raynal
2021-03-03 10:27 ` Colin Ian King
0 siblings, 1 reply; 3+ messages in thread
From: Miquel Raynal @ 2021-03-03 9:46 UTC (permalink / raw)
To: Colin King
Cc: Richard Weinberger, Vignesh Raghavendra, Boris Brezillon,
Sascha Hauer, linux-mtd, kernel-janitors, linux-kernel
Hi Colin,
Colin King <colin.king@canonical.com> wrote on Wed, 3 Mar 2021
09:42:46 +0000:
> 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>
Thanks for the fix, but this has been handled just an hour ago :)
Cheers,
Miquèl
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] mtd: nand: Fix error handling in nand_prog_page_op
2021-03-03 9:46 ` Miquel Raynal
@ 2021-03-03 10:27 ` Colin Ian King
0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2021-03-03 10:27 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, Vignesh Raghavendra, Boris Brezillon,
Sascha Hauer, linux-mtd, kernel-janitors, linux-kernel
On 03/03/2021 09:46, Miquel Raynal wrote:
> Hi Colin,
>
> Colin King <colin.king@canonical.com> wrote on Wed, 3 Mar 2021
> 09:42:46 +0000:
>
>> 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>
>
> Thanks for the fix, but this has been handled just an hour ago :)
Ah, missed that. Glad to know it's fixed.
>
> Cheers,
> Miquèl
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-04 0:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 9:42 [PATCH][next] mtd: nand: Fix error handling in nand_prog_page_op Colin King
2021-03-03 9:46 ` Miquel Raynal
2021-03-03 10:27 ` Colin Ian King
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).