libzfsbootenv: lzbe_set_boot_device(): don't free undefined pointer

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11993
This commit is contained in:
наб 2021-05-03 12:11:30 +02:00 committed by Brian Behlendorf
parent c493943404
commit 87b671f3ac

View 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);
}
}