summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSughosh Ganu <sughosh.ganu@linaro.org>2024-09-09 16:50:17 +0530
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2024-09-19 10:52:50 +0300
commit36811ff8275144a9fe78453023ce1b7e20bd0cf9 (patch)
treeb10b0d9da69efa87cc5f8856971e80350298ec8d
parent5e9feeed8afa7ed4e26766bb15af3d2b04117f4a (diff)
fwu: v1: do a version check for the metadata
Do a sanity check that the version of the FWU metadata that has been read aligns with the version enabled in the image. This allows to indicate an early failure as part of the FWU module initialisation. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Tested-by: Michal Simek <michal.simek@amd.com> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
-rw-r--r--lib/fwu_updates/fwu_v1.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/fwu_updates/fwu_v1.c b/lib/fwu_updates/fwu_v1.c
index efb8d515008..023e43728df 100644
--- a/lib/fwu_updates/fwu_v1.c
+++ b/lib/fwu_updates/fwu_v1.c
@@ -146,6 +146,7 @@ int fwu_init(void)
{
int ret;
uint32_t mdata_size;
+ struct fwu_mdata mdata = {0};
fwu_get_mdata_size(&mdata_size);
@@ -157,10 +158,16 @@ int fwu_init(void)
* Now read the entire structure, both copies, and
* validate that the copies.
*/
- ret = fwu_get_mdata(NULL);
+ ret = fwu_get_mdata(&mdata);
if (ret)
return ret;
+ if (mdata.version != 0x1) {
+ log_err("FWU metadata version %u. Expected value of %u\n",
+ mdata.version, FWU_MDATA_VERSION);
+ return -EINVAL;
+ }
+
fwu_data_init();
return 0;