[PATCH 15/17] state: Fix lseek error check in state_mtd_peb_write()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Don't use 'int' to store lseek()'s return value to avoid problems with
large seek offsets. While at it, make sure to populate return error
code from 'errno'.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 common/state/backend_bucket_circular.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 791f39b9b..4676730d0 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -190,11 +190,10 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir
 
 	offset += circ->eraseblock * circ->mtd->erasesize;
 
-	ret = lseek(circ->fd, offset, SEEK_SET);
-	if (ret < 0) {
+	if (lseek(circ->fd, offset, SEEK_SET) != offset) {
 		dev_err(circ->dev, "Failed to set position for circular write %lld, %d\n",
-			(long long) offset, ret);
-		return ret;
+			(long long) offset, -errno);
+		return -errno;
 	}
 
 	ret = write_full(circ->fd, buf, len);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux