mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <>
Subject: [PATCH] state: backend_raw: fix ignoring unpack failures
Date: Wed, 25 Aug 2021 16:49:04 +0200	[thread overview]
Message-ID: <> (raw)

This is required to inform the state framework that the state variable
set have changed and we need to write the new variable set. Without this
fix the new variable set is never written since the state never sets
dirty=1 and so state_save() will return early without saving the new
variable set.

Signed-off-by: Marco Felsch <>
I keeped the continue instead of break out early so the user gets
informed which variables do not fit.


 common/state/backend_format_raw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
index 5a71149d34..ea962606cc 100644
--- a/common/state/backend_format_raw.c
+++ b/common/state/backend_format_raw.c
@@ -183,6 +183,7 @@ static int backend_format_raw_unpack(struct state_backend_format *format,
 	const struct backend_raw_header *header;
 	const void *data;
 	struct state_backend_format_raw *backend_raw = get_format_raw(format);
+	int ret = 0;
 	header = (const struct backend_raw_header *)buf;
 	data = buf + sizeof(*header);
@@ -191,12 +192,13 @@ static int backend_format_raw_unpack(struct state_backend_format *format,
 		if (sv->start + sv->size > header->data_len) {
 			dev_err(backend_raw->dev, "State variable ends behind valid data, %s\n",
+			ret = -ENOSPC;
 		memcpy(sv->raw, data + sv->start, sv->size);
-	return 0;
+	return ret;
 static int backend_format_raw_pack(struct state_backend_format *format,

barebox mailing list

             reply	other threads:[~2021-08-25 14:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 14:49 Marco Felsch [this message]
2021-10-04 11:50 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox