aboutsummaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2019-06-06 21:04:37 +0000
committerWarner Losh <imp@FreeBSD.org>2019-06-06 21:04:37 +0000
commitfef7bfef6f8c637b3107e1dbefafad3806087b37 (patch)
treef59619844fb1733dfd7e285d035e9322203b7276 /stand
parente5b6bcc7d2f4d1f791bac2ec6beb80f866d81c04 (diff)
downloadsrc-fef7bfef6f8c637b3107e1dbefafad3806087b37.tar.gz
src-fef7bfef6f8c637b3107e1dbefafad3806087b37.zip
Use simple malloc/free instead of dropping down to the UEFI
BootServices AllocatePool/FreePool calls. They are simpler to use and result in the same thing happening. Reviewed by: tsoome@ Differential Revision: https://reviews.freebsd.org/D20540
Notes
Notes: svn path=/head/; revision=348760
Diffstat (limited to 'stand')
-rw-r--r--stand/efi/boot1/ufs_module.c12
-rw-r--r--stand/efi/boot1/zfs_module.c22
2 files changed, 16 insertions, 18 deletions
diff --git a/stand/efi/boot1/ufs_module.c b/stand/efi/boot1/ufs_module.c
index 1611be3e4506..0545dfef39a8 100644
--- a/stand/efi/boot1/ufs_module.c
+++ b/stand/efi/boot1/ufs_module.c
@@ -167,18 +167,18 @@ load(const char *filepath, dev_info_t *dev, void **bufp, size_t *bufsize)
return (EFI_INVALID_PARAMETER);
}
- if ((status = BS->AllocatePool(EfiLoaderData, size, &buf)) !=
- EFI_SUCCESS) {
- printf("Failed to allocate read buffer %zu for '%s' (%lu)\n",
- size, filepath, EFI_ERROR_CODE(status));
- return (status);
+ buf = malloc(size);
+ if (buf == NULL) {
+ printf("Failed to allocate read buffer %zu for '%s'\n",
+ size, filepath);
+ return (EFI_OUT_OF_RESOURCES);
}
read = fsread(ino, buf, size);
if ((size_t)read != size) {
printf("Failed to read '%s' (%zd != %zu)\n", filepath, read,
size);
- (void)BS->FreePool(buf);
+ free(buf);
return (EFI_INVALID_PARAMETER);
}
diff --git a/stand/efi/boot1/zfs_module.c b/stand/efi/boot1/zfs_module.c
index 6eb5aeeb2a06..b381605e3575 100644
--- a/stand/efi/boot1/zfs_module.c
+++ b/stand/efi/boot1/zfs_module.c
@@ -115,19 +115,17 @@ probe(dev_info_t *dev)
{
spa_t *spa;
dev_info_t *tdev;
- EFI_STATUS status;
/* ZFS consumes the dev on success so we need a copy. */
- if ((status = BS->AllocatePool(EfiLoaderData, sizeof(*dev),
- (void**)&tdev)) != EFI_SUCCESS) {
- DPRINTF("Failed to allocate tdev (%lu)\n",
- EFI_ERROR_CODE(status));
- return (status);
+ tdev = malloc(sizeof(*dev));
+ if (tdev == NULL) {
+ DPRINTF("Failed to allocate tdev\n");
+ return (EFI_OUT_OF_RESOURCES);
}
memcpy(tdev, dev, sizeof(*dev));
if (vdev_probe(vdev_read, tdev, &spa) != 0) {
- (void)BS->FreePool(tdev);
+ free(tdev);
return (EFI_UNSUPPORTED);
}
@@ -185,17 +183,17 @@ load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize)
return (EFI_INVALID_PARAMETER);
}
- if ((status = BS->AllocatePool(EfiLoaderData, (UINTN)st.st_size, &buf))
- != EFI_SUCCESS) {
- printf("Failed to allocate load buffer %jd for pool '%s' for '%s' "
- "(%lu)\n", (intmax_t)st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status));
+ buf = malloc(st.st_size);
+ if (buf == NULL) {
+ printf("Failed to allocate load buffer %jd for pool '%s' for '%s' ",
+ (intmax_t)st.st_size, spa->spa_name, filepath);
return (EFI_INVALID_PARAMETER);
}
if ((err = dnode_read(spa, &dn, 0, buf, st.st_size)) != 0) {
printf("Failed to read node from %s (%d)\n", spa->spa_name,
err);
- (void)BS->FreePool(buf);
+ free(buf);
return (EFI_INVALID_PARAMETER);
}