Skip to contentSkip to conversation

cmd/read.c: Fix checking blk_dread return value

PATCH In review Tom Rini 1 participant 2 messages Aug 15, 2017 – Aug 20, 2017

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 cmd/read.c: Fix checking blk_dread return value

The function blk_dread will return -ENOSYS on failure or on success the number of blocks read, which must be the number asked to read (otherwise it failed somewhere). Correct this check.

Reported-by Coverity (CID: 166335)
Cc Philipp Tomsich <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
---
 cmd/read.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/read.c +1 -1
index ecf925426fcc..82c2d9ad994e 100644
@@ -66,7 +66,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 1;
 	}
 
-	if (blk_dread(dev_desc, offset + blk, cnt, addr) < 0) {
+	if (blk_dread(dev_desc, offset + blk, cnt, addr) != cnt) {
 		printf("Error reading blocks\n");
 		return 1;
 	}
Signature · 1 line
1.9.1
author
#1 lore raw
Quoted 9 lines · Tom Rini

The function blk_dread will return -ENOSYS on failure or on success the number of blocks read, which must be the number asked to read (otherwise it failed somewhere). Correct this check.

Reported-by Coverity (CID: 166335)
Cc Philipp Tomsich <[email protected]>
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170820/0dbc5d15/attachment.sig>