[PATCH v5 09/10] tools: spkgimage: add Renesas SPKG format
Marek Vasut
marek.vasut at mailbox.org
Sun May 7 18:08:33 CEST 2023
On 4/24/23 03:15, Ralph Siemsen wrote:
> Renesas RZ/N1 devices contain BootROM code that loads a custom SPKG
> image from QSPI, NAND or USB DFU. Support this format in mkimage tool.
>
> SPKGs can optionally be signed, however creation of signed SPKG is not
> currently supported.
>
> Example of how to use it:
>
> tools/mkimage -n board/schneider/rzn1-snarc/spkgimage.cfg \
> -T spkgimage -a 0x20040000 -e 0x20040000 \
> -d u-boot.bin u-boot.bin.spkg
>
> The config file (spkgimage.cfg in this example) contains additional
> parameters such as NAND ECC settings.
>
> Signed-off-by: Ralph Siemsen <ralph.siemsen at linaro.org>
> Reviewed-by: Simon Glass <sjg at chromium.org>
> squash! tools: spkgimage: add Renesas SPKG format
[...]
> +static int spkgimage_parse_config_file(char *filename)
> +{
> + FILE *fcfg;
> + char line[256];
> + size_t line_num = 0;
> +
> + fcfg = fopen(filename, "r");
> + if (!fcfg)
> + return -EINVAL;
> +
> + conf = calloc(1, sizeof(struct config_file));
> + if (!conf)
> + return -ENOMEM;
> +
> + while (fgets(line, sizeof(line), fcfg)) {
> + line_num += 1;
> +
> + /* Skip blank lines and comments */
> + if (line[0] == '\n' || line[0] == '#')
> + continue;
> +
> + /* Strip any trailing newline */
> + line[strcspn(line, "\n")] = 0;
> +
> + /* Parse the line */
> + if (spkgimage_parse_config_line(line, line_num))
> + return -EINVAL;
Wouldn't this return -EINVAL; leak memory allocated by the calloc() above?
[...]
With that fixed:
Reviewed-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
More information about the U-Boot
mailing list