From b85142e1cbd47366684675a8d79ede23f157c079 Mon Sep 17 00:00:00 2001 From: Ulrich Ölmann Date: Mon, 30 Sep 2019 09:26:04 +0200 Subject: state: Fix lseek error check in state_mtd_peb_write() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ports the following barebox commit: | commit 5eadd11d4795afb6b521b5c3249c6341c0be7117 | Author: Andrey Smirnov | Date: Wed Mar 6 23:49:24 2019 -0800 | | 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 | Signed-off-by: Sascha Hauer Signed-off-by: Ulrich Ölmann --- src/barebox-state/backend_bucket_circular.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/barebox-state/backend_bucket_circular.c b/src/barebox-state/backend_bucket_circular.c index 8cc7514..b2577bc 100644 --- a/src/barebox-state/backend_bucket_circular.c +++ b/src/barebox-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); -- cgit v1.2.3