summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Ölmann <u.oelmann@pengutronix.de>2019-09-30 09:26:03 +0200
committerRoland Hieber <rhi@pengutronix.de>2019-10-11 16:49:38 +0200
commitf234f3ec94984ee1988d526bafee02a37067b415 (patch)
treec9163da307df5673e2ab726e9a3b5d436d46ac2e
parentd59af7f22ab49c2d4c900584ca28d76bf921d068 (diff)
downloaddt-utils-f234f3ec94984ee1988d526bafee02a37067b415.tar.gz
dt-utils-f234f3ec94984ee1988d526bafee02a37067b415.tar.xz
state: Fix lseek error check in state_mtd_peb_read()
This ports the following barebox commit: | commit 8a6a9fbcecffab1b076edfad94d4f32bb2cc9435 | Author: Andrey Smirnov <andrew.smirnov@gmail.com> | Date: Wed Mar 6 23:49:23 2019 -0800 | | 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> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
-rw-r--r--src/barebox-state/backend_bucket_circular.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/barebox-state/backend_bucket_circular.c b/src/barebox-state/backend_bucket_circular.c
index f665c3b..8cc7514 100644
--- a/src/barebox-state/backend_bucket_circular.c
+++ b/src/barebox-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,