summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-06 23:49:24 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 07:55:46 +0100
commit5eadd11d4795afb6b521b5c3249c6341c0be7117 (patch)
tree966988d993260c319cbd7c4ebc2f15f77c072dd7
parent8a6a9fbcecffab1b076edfad94d4f32bb2cc9435 (diff)
downloadbarebox-5eadd11d4795afb6b521b5c3249c6341c0be7117.tar.gz
barebox-5eadd11d4795afb6b521b5c3249c6341c0be7117.tar.xz
state: Fix lseek error check in state_mtd_peb_write()
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@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/state/backend_bucket_circular.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 791f39b9b6..4676730d05 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);