The version 2 of the FWU metadata has a top level structure, followed
by optional information on the updatable images. Perform some sanity
checks on some of the fields in the top level structure to determine
if the rest of the structure has to be read.

Signed-off-by: Sughosh Ganu <sughosh.g...@linaro.org>
---
 lib/fwu_updates/fwu_v2.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/lib/fwu_updates/fwu_v2.c b/lib/fwu_updates/fwu_v2.c
index 108bc9bb4a..d0d8a25929 100644
--- a/lib/fwu_updates/fwu_v2.c
+++ b/lib/fwu_updates/fwu_v2.c
@@ -58,24 +58,6 @@ static int fwu_mdata_sanity_checks(void)
        struct fwu_data *data = fwu_get_data();
        struct fwu_mdata *mdata = data->fwu_mdata;
 
-       if (mdata->version != FWU_MDATA_VERSION) {
-               log_err("FWU metadata version %u. Expected value of %u\n",
-                       mdata->version, FWU_MDATA_VERSION);
-               return -EINVAL;
-       }
-
-       if (!mdata->desc_offset) {
-               log_err("No image information provided with the Metadata. ");
-               log_err("Image information expected in the metadata\n");
-               return -EINVAL;
-       }
-
-       if (mdata->desc_offset != 0x20) {
-               log_err("Descriptor Offset(0x%x) in the FWU Metadata not equal 
to 0x20\n",
-                       mdata->desc_offset);
-               return -EINVAL;
-       }
-
        num_banks = fwu_get_fw_desc(mdata)->num_banks;
        num_images = fwu_get_fw_desc(mdata)->num_images;
 
@@ -238,6 +220,24 @@ int fwu_init(void)
                return ret;
        }
 
+       if (mdata.version != FWU_MDATA_VERSION) {
+               log_err("FWU metadata version %u. Expected value of %u\n",
+                       mdata.version, FWU_MDATA_VERSION);
+               return -EINVAL;
+       }
+
+       if (!mdata.desc_offset) {
+               log_err("No image information provided with the Metadata. ");
+               log_err("Image information expected in the metadata\n");
+               return -EINVAL;
+       }
+
+       if (mdata.desc_offset != 0x20) {
+               log_err("Descriptor Offset(0x%x) in the FWU Metadata not equal 
to 0x20\n",
+                       mdata.desc_offset);
+               return -EINVAL;
+       }
+
        ret = fwu_mdata_copies_allocate(mdata.metadata_size);
        if (ret)
                return ret;
-- 
2.34.1

Reply via email to