git: 5328f9034fc4 - main - stand/kboot: Simplify
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 01 May 2023 21:04:21 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5328f9034fc410b105629700a1309bebf094266a commit 5328f9034fc410b105629700a1309bebf094266a Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2023-05-01 15:28:32 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2023-05-01 21:02:53 +0000 stand/kboot: Simplify There's plenty of stack in kboot, so use it here rather than the malloc/free dance. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D39416 --- stand/kboot/hostdisk.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/stand/kboot/hostdisk.c b/stand/kboot/hostdisk.c index 5cc7825034dd..d28530891e0e 100644 --- a/stand/kboot/hostdisk.c +++ b/stand/kboot/hostdisk.c @@ -574,7 +574,6 @@ probe_zfs_currdev(uint64_t pool_guid, uint64_t root_guid, bool setcurrdev) { char *devname; struct zfs_devdesc currdev; - char *buf = NULL; bool bootable; currdev.dd.d_dev = &zfs_dev; @@ -587,18 +586,15 @@ probe_zfs_currdev(uint64_t pool_guid, uint64_t root_guid, bool setcurrdev) 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); - if (setcurrdev) - 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); + if (setcurrdev) + set_currdev(buf); + setenv("zfs-bootonce", buf, 1); } + (void)zfs_attach_nvstore(&currdev); init_zfs_boot_options(devname); } return (bootable);