summaryrefslogtreecommitdiffstats
path: root/common/state/backend_bucket_direct.c
diff options
context:
space:
mode:
authorDaniel Schultz <d.schultz@phytec.de>2018-04-12 11:13:01 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-04-16 09:54:11 +0200
commit67c1c0853fa06bcbc1725e93b6ad9942e80a1e56 (patch)
treee7595ca6de862364a112767a6c3ca09995f62833 /common/state/backend_bucket_direct.c
parent6377d27b951bfddc67bba16e83f79ae1d9fa8eb9 (diff)
downloadbarebox-67c1c0853fa06bcbc1725e93b6ad9942e80a1e56.tar.gz
common: state: Add property to protect existing data
After an update to a newer barebox version with an enabled state framework, existing data in storage memories could be overwritten. Add a new property to check in front of every write task, if the meta magic field only contains the magic number, zeros or ones. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state/backend_bucket_direct.c')
-rw-r--r--common/state/backend_bucket_direct.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index 958696e..9d6a337 100644
--- a/common/state/backend_bucket_direct.c
+++ b/common/state/backend_bucket_direct.c
@@ -69,6 +69,8 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
if (meta.magic == direct_magic) {
read_len = meta.written_length;
} else {
+ if (meta.magic != ~0 && !!meta.magic)
+ bucket->wrong_magic = 1;
if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
dev_err(direct->dev, "No meta data header found\n");
dev_dbg(direct->dev, "Enable backward compatibility or increase stride size\n");