summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-03-18 08:48:17 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-03-18 08:48:17 +0100
commit8c02f14d1db16068a005b9674da42f14f344ab89 (patch)
treeb57b9d55789ab59e63436ff70f569db06c228f50 /common
parent52ef5245746cb13d1eaf9d520d9e7a36d2a70d4b (diff)
parent544bd2f460da25de41094aceadb799ca31474d97 (diff)
downloadbarebox-8c02f14d1db16068a005b9674da42f14f344ab89.tar.gz
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r--common/state/backend_storage.c2
-rw-r--r--common/state/state.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c
index fca887e..fe7e89e 100644
--- a/common/state/backend_storage.c
+++ b/common/state/backend_storage.c
@@ -192,6 +192,7 @@ int state_storage_read(struct state_backend_storage *storage,
/* Free buffer from the unused buckets */
free(bucket->buf);
bucket->buf = NULL;
+ bucket->len = 0;
}
/*
@@ -204,6 +205,7 @@ int state_storage_read(struct state_backend_storage *storage,
/* buffer from the used bucket is passed to the caller, do not free */
bucket_used->buf = NULL;
+ bucket_used->len = 0;
return 0;
}
diff --git a/common/state/state.c b/common/state/state.c
index b168387..1822f37 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -94,7 +94,7 @@ out:
*/
static int state_do_load(struct state *state, enum state_flags flags)
{
- void *buf;
+ void *buf = NULL;
ssize_t len;
int ret;
@@ -103,7 +103,7 @@ static int state_do_load(struct state *state, enum state_flags flags)
if (ret) {
dev_err(&state->dev, "Failed to read state with format %s, %d\n",
state->format->name, ret);
- return ret;
+ goto out;
}
ret = state->format->unpack(state->format, state, buf, len);
@@ -114,9 +114,8 @@ static int state_do_load(struct state *state, enum state_flags flags)
}
state->init_from_defaults = 0;
- state->dirty = 0;
-
out:
+ state->dirty = !!ret; /* mark dirty on error */
free(buf);
return ret;
}