diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/state/backend_storage.c | 2 | ||||
-rw-r--r-- | common/state/state.c | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c index fca887e93f..fe7e89e8fb 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 b168387eef..1822f37f3e 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; } |