Am 2. Oktober 2026 11:26:38 MESZ schrieb "Vincent Stehlé" <[email protected]>: >On Thu, Oct 01, 2026 at 03:55:10PM +0200, Heinrich Schuchardt wrote: >> On 9/22/26 16:58, Vincent Stehlé wrote: >> > Add a minimal test for the UEFI Firmware Management Protocol. >(..) >> > + /* Determine buffer size */ >> > + img_info_size = 0; >> > + ret = fmp->get_image_info(fmp, &img_info_size, NULL, NULL, NULL, NULL, >> > + NULL, NULL); >> > + if (ret != EFI_BUFFER_TOO_SMALL) { >> > + efi_st_error("GetImageInfo returned %u\n", (unsigned int)ret); >> > + goto out; >> > + } >> >> This fails if the number of images is 0. >> >> ERROR: GetImageInfo returned 2 (EFI_INVALID_PARAMETER) >> >> +struct efi_fw_image fw_images[] = { >> +}; >> + >> +struct efi_capsule_update_info update_info = { >> + .dfu_string = NULL, >> + .num_images = ARRAY_SIZE(fw_images), >> + .images = fw_images, >> +}; >> >> This looks like a bug in efi_fill_image_desc_array((). Why does it return >> EFI_INVALID_PARAMETER if the number of images is 0? >> >> We should just return *img_info_size = 0 and EFI_SUCCESS instead. >> >> The test should return EFI_ST_SUCCESS in this case. > >Hi Heinrich, > >Thank you very much for reviewing. > >I confirm that I could reproduce this corner case with your changes. > >In the end I think the test (v2) itself is fine, as it does pass when I >replace the calls to get_image_info() by the following code: > >+ img_info = NULL; >+ desc_ver = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION; >+ desc_cnt = 0; >+ desc_size = sizeof(struct efi_firmware_image_descriptor); >+ pkg_ver = 0; >+ pkg_ver_name = NULL; > >I will try to send a fix for efi_fill_image_desc_array() as you >mentioned, but if you agree that will be separated from this series.
The UEFI specification does not define if AllocatePool(size = 0) may return NULL which would lead to a failure of the subsequent Free(). I think we should return if size = 0 before trying to allocate memory. Best regards Heinrich > >Best regards, >Vincent. > >> >> Best regards >> >> Heinrich
