summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-06 23:49:22 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 07:55:46 +0100
commitec25ecfbcb47cb83b310b9e177a5b65de3781dec (patch)
treef92c3abb12f52f59fdf17fee3904f735587e8097 /common
parent219b954a11e82afbbd7b6ef13d8c5ba94a5b0ff3 (diff)
downloadbarebox-ec25ecfbcb47cb83b310b9e177a5b65de3781dec.tar.gz
barebox-ec25ecfbcb47cb83b310b9e177a5b65de3781dec.tar.xz
state: Fix lseek error check in state_backend_bucket_direct_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>
Diffstat (limited to 'common')
-rw-r--r--common/state/backend_bucket_direct.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index 1524312146..95ddb93106 100644
--- a/common/state/backend_bucket_direct.c
+++ b/common/state/backend_bucket_direct.c
@@ -113,10 +113,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
if (len > direct->max_size - sizeof(meta))
return -E2BIG;
- ret = lseek(direct->fd, direct->offset, SEEK_SET);
- if (ret < 0) {
- dev_err(direct->dev, "Failed to seek file, %d\n", ret);
- return ret;
+ if (lseek(direct->fd, direct->offset, SEEK_SET) != direct->offset) {
+ dev_err(direct->dev, "Failed to seek file, %d\n", -errno);
+ return -errno;
}
/* write the meta data only if there is head room */