On 27.01.21 09:33, Christian Storm wrote: > From: Christian Storm <[email protected]> > > The home-brew mfree() is actually superfluous as > GNU EFI's lib/misc.c implements > VOID FreePool(VOID *Buffer) > as also just calling > uefi_call_wrapper(BS->FreePool, 1, Buffer) > and it is a public API function (inc/efilib.h). > > FreePool() returns VOID while the home-brew mfree() > returns EFI_STATUS -- which is however never checked > here anyway. > The possible EFI_STATUS return values are: > EFI_SUCCESS - The memory was returned to the system. > EFI_INVALID_PARAMETER - Buffer was invalid. > So it's probably OK to do it as FreePool() does and > ignore the return value. > > Hence, drop own mfree(). > > Signed-off-by: Christian Storm <[email protected]> > --- > env/fatvars.c | 4 ++-- > include/utils.h | 1 - > main.c | 6 +++--- > utils.c | 21 ++++++++------------- > 4 files changed, 13 insertions(+), 19 deletions(-) > > diff --git a/env/fatvars.c b/env/fatvars.c > index 10593b6..4cf580d 100644 > --- a/env/fatvars.c > +++ b/env/fatvars.c > @@ -80,7 +80,7 @@ BG_STATUS save_current_config(void) > > result = BG_SUCCESS; > scc_cleanup: > - mfree(config_volumes); > + FreePool(config_volumes); > return result; > } > > @@ -221,7 +221,7 @@ BG_STATUS load_config(BG_LOADER_PARAMS *bglp) > INFO(L" timeout: %d seconds\n", bglp->timeout); > > lc_cleanup: > - mfree(config_volumes); > + FreePool(config_volumes); > return result; > } > > diff --git a/include/utils.h b/include/utils.h > index eb00a33..825a647 100644 > --- a/include/utils.h > +++ b/include/utils.h > @@ -34,7 +34,6 @@ typedef enum { DOSFSLABEL, CUSTOMLABEL, NOLABEL } LABELMODE; > > uint32_t calc_crc32(void *data, int32_t size); > void __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS > status); > -EFI_STATUS mfree(VOID *p); > CHAR16 *get_volume_label(EFI_FILE_HANDLE fh); > EFI_STATUS get_volumes(VOLUME_DESC **volumes, UINTN *count); > EFI_STATUS close_volumes(VOLUME_DESC *volumes, UINTN count); > diff --git a/main.c b/main.c > index 2bbd2ad..682f5c8 100644 > --- a/main.c > +++ b/main.c > @@ -126,7 +126,7 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, > EFI_SYSTEM_TABLE *system_table) > > tmp = DevicePathToStr(DevicePathFromHandle(loaded_image->DeviceHandle)); > boot_medium_path = GetBootMediumPath(tmp); > - mfree(tmp); > + FreePool(tmp); > INFO(L"Boot medium: %s\n", boot_medium_path); > > status = get_volumes(&volumes, &volume_count); > @@ -178,8 +178,8 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, > EFI_SYSTEM_TABLE *system_table) > error_exit(L"Could not load specified kernel image.", status); > } > > - mfree(payload_dev_path); > - mfree(boot_medium_path); > + FreePool(payload_dev_path); > + FreePool(boot_medium_path); > > status = > uefi_call_wrapper(BS->OpenProtocol, 6, payload_handle, > diff --git a/utils.c b/utils.c > index 0ba22f3..9f59b1e 100644 > --- a/utils.c > +++ b/utils.c > @@ -39,12 +39,12 @@ BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp) > > tmp = DevicePathToStr(dp); > device_path = GetBootMediumPath(tmp); > - mfree(tmp); > + FreePool(tmp); > > if (StrCmp(device_path, boot_medium_path) == 0) { > result = TRUE; > } > - mfree(device_path); > + FreePool(device_path); > > return result; > } > @@ -65,11 +65,6 @@ void __attribute__((noreturn)) error_exit(CHAR16 *message, > EFI_STATUS status) > __builtin_unreachable(); > } > > -EFI_STATUS mfree(VOID *p) > -{ > - return uefi_call_wrapper(BS->FreePool, 1, p); > -} > - > CHAR16 *get_volume_label(EFI_FILE_HANDLE fh) > { > EFI_FILE_SYSTEM_INFO *fsi; > @@ -85,7 +80,7 @@ CHAR16 *get_volume_label(EFI_FILE_HANDLE fh) > status = > uefi_call_wrapper(fh->GetInfo, 4, fh, &fsiGuid, &fsis, (VOID *)fsi); > if (EFI_ERROR(status) || fsis == 0) { > - mfree(fsi); > + FreePool(fsi); > return NULL; > } > return fsi->VolumeLabel; > @@ -183,7 +178,7 @@ EFI_STATUS get_volumes(VOLUME_DESC **volumes, UINTN > *count) > devpathstr, (*volumes)[rootCount].fslabel, > (*volumes)[rootCount].fscustomlabel); > > - mfree(devpathstr); > + FreePool(devpathstr); > > rootCount++; > } > @@ -214,7 +209,7 @@ EFI_STATUS close_volumes(VOLUME_DESC *volumes, UINTN > count) > result = EFI_DEVICE_ERROR; > } > } > - mfree(volumes); > + FreePool(volumes); > return result; > } > > @@ -278,8 +273,8 @@ EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE > device, > StrCat(fullpath, payloadpath + prefixlen + 3); > INFO(L"Full path for kernel is: %s\n", fullpath); > > - mfree(fullpath); > - mfree(pathprefix); > + FreePool(fullpath); > + FreePool(pathprefix); > > EFI_DEVICE_PATH *filedevpath; > EFI_DEVICE_PATH *appendeddevpath; > @@ -287,7 +282,7 @@ EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE > device, > filedevpath = FileDevicePath(NULL, payloadpath + prefixlen + 3); > appendeddevpath = AppendDevicePath(devpath, filedevpath); > > - mfree(filedevpath); > + FreePool(filedevpath); > > return appendeddevpath; > } >
Thanks, both applied to next. Jan -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/ef124f2c-e2fa-fde9-6232-f7881627430c%40siemens.com.
