On Sun, Jul 26, 2020 at 02:00:33PM -0300, Fabio Estevam wrote: > On Sun, Jul 26, 2020 at 12:05 PM Tom Rini <tr...@konsulko.com> wrote: > > > We just need to use calloc() in the tool and not mess with alignment. > > Like this? > > --- a/tools/fit_image.c > +++ b/tools/fit_image.c > @@ -446,7 +446,6 @@ static int fit_extract_data(struct > image_tool_params *params, const char *fname) > int ret; > int images; > int node; > - int image_number; > int align_size; > > align_size = params->bl_len ? params->bl_len : 4; > @@ -461,13 +460,12 @@ static int fit_extract_data(struct > image_tool_params *params, const char *fname) > ret = -EINVAL; > goto err_munmap; > } > - image_number = fdtdec_get_child_count(fdt, images); > > /* > * Allocate space to hold the image data we will extract, > * extral space allocate for image alignment to prevent overflow. > */ > - buf = malloc(fit_size + (align_size * image_number)); > + buf = calloc(1, fit_size); > if (!buf) { > ret = -ENOMEM; > goto err_munmap; > > If this is not the right approach, care to propose a patch?
I mean just literally changing the malloc(...) to calloc(1, ...), audit any other malloc(...) calls in the file and change nothing else. Thanks! -- Tom
signature.asc
Description: PGP signature