summaryrefslogtreecommitdiffstats
path: root/src/interface/efi
diff options
context:
space:
mode:
authorIgnat Korchagin2020-07-21 23:27:08 +0200
committerMichael Brown2020-07-22 13:54:18 +0200
commitb76052335788d0ad2c4b0bded116c3b02dd4bbc2 (patch)
treecf81b538095e393dc6105bcbe340fbac89ec1570 /src/interface/efi
parent[cmdline] Add "--timeout" parameter to "ifconf" command (diff)
downloadipxe-b76052335788d0ad2c4b0bded116c3b02dd4bbc2.tar.gz
ipxe-b76052335788d0ad2c4b0bded116c3b02dd4bbc2.tar.xz
ipxe-b76052335788d0ad2c4b0bded116c3b02dd4bbc2.zip
[efi] Check the status code from AllocatePool()
According to the latest UEFI specification (Version 2.8 Errata B) p. 7.2: "Buffer: A pointer to a pointer to the allocated buffer if the call succeeds; undefined otherwise." So implementations are obliged neither to return NULL, if the allocation fails, nor to preserve the contents of the pointer. Make the logic more reliable by checking the status code from AllocatePool() instead of checking the returned pointer for NULL Signed-off-by: Ignat Korchagin <ignat@cloudflare.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi')
-rw-r--r--src/interface/efi/efi_snp_hii.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/interface/efi/efi_snp_hii.c b/src/interface/efi/efi_snp_hii.c
index 651bef040..1e681a429 100644
--- a/src/interface/efi/efi_snp_hii.c
+++ b/src/interface/efi/efi_snp_hii.c
@@ -247,16 +247,17 @@ static int efi_snp_hii_append ( struct efi_snp_device *snpdev __unused,
const char *key, const char *value,
wchar_t **results ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ EFI_STATUS efirc;
size_t len;
void *new;
/* Allocate new string */
len = ( ( *results ? ( wcslen ( *results ) + 1 /* "&" */ ) : 0 ) +
strlen ( key ) + 1 /* "=" */ + strlen ( value ) + 1 /* NUL */ );
- bs->AllocatePool ( EfiBootServicesData, ( len * sizeof ( wchar_t ) ),
- &new );
- if ( ! new )
- return -ENOMEM;
+ if ( ( efirc = bs->AllocatePool ( EfiBootServicesData,
+ ( len * sizeof ( wchar_t ) ),
+ &new ) ) != 0 )
+ return -EEFI ( efirc );
/* Populate string */
efi_snprintf ( new, len, "%ls%s%s=%s", ( *results ? *results : L"" ),