mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] state: backend_raw: fix ignoring unpack failures
@ 2021-08-25 14:49 Marco Felsch
  2021-10-04 11:50 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Marco Felsch @ 2021-08-25 14:49 UTC (permalink / raw)
  To: barebox

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 <m.felsch@pengutronix.de>
---
I keeped the continue instead of break out early so the user gets
informed which variables do not fit.

Regards,
  Marco

 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",
 				sv->name);
+			ret = -ENOSPC;
 			continue;
 		}
 		memcpy(sv->raw, data + sv->start, sv->size);
 	}
 
-	return 0;
+	return ret;
 }
 
 static int backend_format_raw_pack(struct state_backend_format *format,
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-04 11:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 14:49 [PATCH] state: backend_raw: fix ignoring unpack failures Marco Felsch
2021-10-04 11:50 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox