[PATCH] state: backend_raw: fix ignoring unpack failures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux