]> git.proxmox.com Git - mirror_zfs.git/commitdiff
libzfsbootenv: lzbe_set_boot_device(): don't free undefined pointer
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Mon, 3 May 2021 10:11:30 +0000 (12:11 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sat, 8 May 2021 16:27:53 +0000 (09:27 -0700)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11993

lib/libzfsbootenv/lzbe_device.c

index b366bd9c7f57d987e50940a6c069d744af850139..2d8833b4fff29c82f32da10d78a991085826baf6 100644 (file)
@@ -88,12 +88,11 @@ lzbe_set_boot_device(const char *pool, lzbe_flags_t flag, const char *device)
                if (strncmp(device, "zfs:", 4) == 0) {
                        fnvlist_add_string(nv, OS_BOOTONCE, device);
                } else {
-                       descriptor = NULL;
-                       if (asprintf(&descriptor, "zfs:%s:", device) > 0)
+                       if (asprintf(&descriptor, "zfs:%s:", device) > 0) {
                                fnvlist_add_string(nv, OS_BOOTONCE, descriptor);
-                       else
+                               free(descriptor);
+                       } else
                                rv = ENOMEM;
-                       free(descriptor);
                }
        }