The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5ce98ee5f42de10d29f3a99719652c272d13c2e7

commit 5ce98ee5f42de10d29f3a99719652c272d13c2e7
Author:     Warner Losh <[email protected]>
AuthorDate: 2023-05-01 15:28:17 +0000
Commit:     Warner Losh <[email protected]>
CommitDate: 2023-05-01 21:02:53 +0000

    stand/userboot: Simplify code
    
    We have way more than 8k of stack for the current value of the zfs
    bootonce attribute. Allocate buf on the stack rather than the
    complicated malloc / free dance.
    
    Sponsored by:           Netflix
    Reviewed by:            tsoome, kevans, jhb
    Differential Revision:  https://reviews.freebsd.org/D39414
---
 stand/userboot/userboot/main.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c
index b134d86de9bd..3dde6f6b4109 100644
--- a/stand/userboot/userboot/main.c
+++ b/stand/userboot/userboot/main.c
@@ -235,7 +235,6 @@ extract_currdev(void)
        struct devdesc *dd;
 #if defined(USERBOOT_ZFS_SUPPORT)
        struct zfs_devdesc zdev;
-       char *buf = NULL;
 
        if (userboot_zfs_found) {
        
@@ -272,17 +271,14 @@ extract_currdev(void)
 
 #if defined(USERBOOT_ZFS_SUPPORT)
        if (userboot_zfs_found) {
-               buf = malloc(VDEV_PAD_SIZE);
-               if (buf != NULL) {
-                       if (zfs_get_bootonce(&zdev, 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(&zdev);
+               char buf[VDEV_PAD_SIZE];
+
+               if (zfs_get_bootonce(&zdev, OS_BOOTONCE, buf, sizeof(buf)) == 
0) {
+                       printf("zfs bootonce: %s\n", buf);
+                       set_currdev(buf);
+                       setenv("zfs-bootonce", buf, 1);
                }
+               (void)zfs_attach_nvstore(&zdev);
        }
 #endif
 }

Reply via email to