Date: Thu, 6 Jun 2019 21:04:38 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348760 - head/stand/efi/boot1 Message-ID: <201906062104.x56L4cQE024644@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Thu Jun 6 21:04:37 2019 New Revision: 348760 URL: https://svnweb.freebsd.org/changeset/base/348760 Log: 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 Modified: head/stand/efi/boot1/ufs_module.c head/stand/efi/boot1/zfs_module.c Modified: head/stand/efi/boot1/ufs_module.c ============================================================================== --- head/stand/efi/boot1/ufs_module.c Thu Jun 6 20:54:09 2019 (r348759) +++ head/stand/efi/boot1/ufs_module.c Thu Jun 6 21:04:37 2019 (r348760) @@ -167,18 +167,18 @@ load(const char *filepath, dev_info_t *dev, void **buf 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); } Modified: head/stand/efi/boot1/zfs_module.c ============================================================================== --- head/stand/efi/boot1/zfs_module.c Thu Jun 6 20:54:09 2019 (r348759) +++ head/stand/efi/boot1/zfs_module.c Thu Jun 6 21:04:37 2019 (r348760) @@ -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 * 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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906062104.x56L4cQE024644>