]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: kwbimage: Add missing check for maximal value for DATA_DELAY
authorPali Rohár <pali@kernel.org>
Wed, 12 Jan 2022 17:20:48 +0000 (18:20 +0100)
committerStefan Roese <sr@denx.de>
Fri, 14 Jan 2022 10:39:16 +0000 (11:39 +0100)
Data delay is stored as 8-bit number in kwbimage structure. Ensure the
given value is at most 255.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
tools/kwbimage.c

index 7c2106006ad7669bf9b20250d3f40db7a5a5a7f3..2de8c371c12a2141f2ed162def5bd76b4f95332c 100644 (file)
@@ -1659,6 +1659,10 @@ static int image_create_config_parse_oneline(char *line,
                        el->regdata_delay = REGISTER_SET_HDR_OPT_DELAY_SDRAM_SETUP;
                else
                        el->regdata_delay = REGISTER_SET_HDR_OPT_DELAY_MS(strtoul(value1, NULL, 10));
+               if (el->regdata_delay > 255) {
+                       fprintf(stderr, "Maximal DATA_DELAY is 255\n");
+                       return -1;
+               }
                break;
        case IMAGE_CFG_BAUDRATE:
                el->baudrate = strtoul(value1, NULL, 10);