[PATCH] efi_loader: Assure fitImage from capsule is used from 8-byte aligned address
Ilias Apalodimas
ilias.apalodimas at linaro.org
Thu Nov 20 07:10:10 CET 2025
On Wed, 19 Nov 2025 at 19:34, Marek Vasut <marek.vasut at mailbox.org> wrote:
>
> On 11/18/25 2:56 PM, Ilias Apalodimas wrote:
>
> Hello Ilias,
>
> sorry for my slow response, I am buried under emails.
No worries
>
> >>>> + img = memalign(8, image_size);
> >>>> + if (!img)
> >>>> + return EFI_EXIT(EFI_BAD_BUFFER_SIZE);
> >>>> + memcpy(img, image, image_size);
> >>>> + } else {
> >>>> + img = (void *)image;
> >>>> + }
> >>>> +
> >>>> + ret = fit_update(img);
> >>>> +
> >>>> + if ((uintptr_t)image & 7)
> >>>> + free(img);
> >>>
> >>> Initialize img to NULL and make the check a bit simpler to read (or
> >>> get rid of it overall)
> >> This part ^ I do not understand. The img variable is used by
> >> fit_update(img) , where should it be initialized to NULL ?
> >
> > The patch might be misleading since it doesn't show the entire
> > function. But from what I saw 'img' is only initialized when
> > 'if ((uintptr_t)image & 7)' is true. you can initialize img to NULL on
> > the declaration and just check for that.
>
> The 'img' is always initialized, see this:
>
> "
> + if ((uintptr_t)image & 7) {
> + img = memalign(8, image_size);
> ^^^ ----------------------- Here it is initialized
> + if (!img)
> + return EFI_EXIT(EFI_BAD_BUFFER_SIZE);
> + memcpy(img, image, image_size);
> + } else {
> + img = (void *)image;
> ^^^ ----------------------- Here it is initialized too
> + }
> "
Which I somehow missed reading the patch...
Thanks
/Ilias
More information about the U-Boot
mailing list