From: Tom Rini <trini@konsulko.com>
Date: Tue, 15 Aug 2017 01:02:08 +0000 (-0400)
Subject: fs/fat: Correct blk_dread() return value check
X-Git-Tag: v2025.01-rc5-pxa1908~5997
X-Git-Url: http://git.dujemihanovic.xyz/html/static/git-logo.png?a=commitdiff_plain;h=42a9f147d87b6e4442d6c3074c34b08854f36ef5;p=u-boot.git

fs/fat: Correct blk_dread() return value check

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.

Signed-off-by: Tom Rini <trini@konsulko.com>
---

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 9ad18f96ff..465a6875ed 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -54,7 +54,7 @@ static int disk_read(__u32 block, __u32 nr_blocks, void *buf)
 
 	ret = blk_dread(cur_dev, cur_part_info.start + block, nr_blocks, buf);
 
-	if (nr_blocks && ret == 0)
+	if (ret != nr_blocks)
 		return -1;
 
 	return ret;