[PATCH 1/6] fwu: v2: perform some checks before reading metadata
Michal Simek
michal.simek at amd.com
Wed Sep 4 10:43:47 CEST 2024
On 8/30/24 13:40, Sughosh Ganu wrote:
> 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.ganu at 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;
> + }
nit:
One more thing here. You are doing this just to report that desc_offset is not 0
and below it is equal to 0x20. I think you can check directly that it is 0x20.
M
More information about the U-Boot
mailing list