diff --git a/lib/libzfsbootenv/lzbe_device.c b/lib/libzfsbootenv/lzbe_device.c index b366bd9c7f..2d8833b4ff 100644 --- a/lib/libzfsbootenv/lzbe_device.c +++ b/lib/libzfsbootenv/lzbe_device.c @@ -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); } }