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
1 changed files with 3 additions and 4 deletions

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) { if (strncmp(device, "zfs:", 4) == 0) {
fnvlist_add_string(nv, OS_BOOTONCE, device); fnvlist_add_string(nv, OS_BOOTONCE, device);
} else { } else {
descriptor = NULL; if (asprintf(&descriptor, "zfs:%s:", device) > 0) {
if (asprintf(&descriptor, "zfs:%s:", device) > 0)
fnvlist_add_string(nv, OS_BOOTONCE, descriptor); fnvlist_add_string(nv, OS_BOOTONCE, descriptor);
else free(descriptor);
} else
rv = ENOMEM; rv = ENOMEM;
free(descriptor);
} }
} }