]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
tools: mkfwumdata: Add bank count validation for FWU metadata v2
authorKory Maincent <kory.maincent@bootlin.com>
Mon, 23 Feb 2026 13:18:38 +0000 (14:18 +0100)
committerIlias Apalodimas <ilias.apalodimas@linaro.org>
Thu, 26 Mar 2026 06:20:00 +0000 (08:20 +0200)
The FWU metadata specification version 2 supports a maximum of 4 banks.
Add validation to enforce this limit and prevent creation of non-compliant
metadata structures when using version 2.

Without this check, users could inadvertently create invalid metadata by
specifying more than 4 banks, leading to potential compatibility issues
with FWU-compliant firmware update implementations.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Tested-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
tools/fwumdata_src/mkfwumdata.c

index 5ceec7a298033429deeee28c7f555988555096e9..8b25539fd57afe634811d03df71830dbc6e2883a 100644 (file)
@@ -471,6 +471,12 @@ int main(int argc, char *argv[])
                return -EINVAL;
        }
 
+       if (version == 2 && banks > MAX_BANKS_V2) {
+               fprintf(stderr, "Error: Version 2 supports maximum %d banks, %ld requested.\n",
+                       MAX_BANKS_V2, banks);
+               return -EINVAL;
+       }
+
        /* This command takes UUIDs * images and output file. */
        if (optind + images + 1 != argc) {
                fprintf(stderr,