From d5babd0d23769d365a83bebc0a5cd8cbfb55564d Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Mon, 1 May 2023 09:28:25 -0600 Subject: [PATCH] stand/efi: Simplify code here We have plenty of stack in the EFI case, so use it instead of the complicated malloc / free dance. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D39415 --- stand/efi/loader/main.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 9ff5f1dd767..e5f9b40ae55 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -252,7 +252,6 @@ probe_zfs_currdev(uint64_t guid) { char *devname; struct zfs_devdesc currdev; - char *buf = NULL; bool bootable; currdev.dd.d_dev = &zfs_dev; @@ -265,18 +264,16 @@ probe_zfs_currdev(uint64_t guid) bootable = sanity_check_currdev(); if (bootable) { - buf = malloc(VDEV_PAD_SIZE); - if (buf != NULL) { - if (zfs_get_bootonce(&currdev, OS_BOOTONCE, buf, - VDEV_PAD_SIZE) == 0) { - printf("zfs bootonce: %s\n", buf); - set_currdev(buf); - setenv("zfs-bootonce", buf, 1); - } - free(buf); - (void) zfs_attach_nvstore(&currdev); + char buf[VDEV_PAD_SIZE]; + + if (zfs_get_bootonce(&currdev, OS_BOOTONCE, buf, sizeof(buf)) == 0) { + printf("zfs bootonce: %s\n", buf); + set_currdev(buf); + setenv("zfs-bootonce", buf, 1); } + (void)zfs_attach_nvstore(&currdev); } + return (bootable); } #endif