summaryrefslogtreecommitdiffstats
path: root/common/state
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-06 23:49:23 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 07:55:46 +0100
commit8a6a9fbcecffab1b076edfad94d4f32bb2cc9435 (patch)
treee48f3a4ddbf42b34ffb19417ddc538a734085f8f /common/state
parentec25ecfbcb47cb83b310b9e177a5b65de3781dec (diff)
downloadbarebox-8a6a9fbcecffab1b076edfad94d4f32bb2cc9435.tar.gz
state: Fix lseek error check in state_mtd_peb_read()
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>
Diffstat (limited to 'common/state')
-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 da7c842..791f39b 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -162,11 +162,10 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ
offset += (off_t)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 circular read position to %lld, %d\n",
- (long long) offset, ret);
- return ret;
+ (long long) offset, -errno);
+ return -errno;
}
dev_dbg(circ->dev, "Read state from %lld length %d\n", (long long) offset,