summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-05-03 12:11:30 +0200
committerBrian Behlendorf <[email protected]>2021-05-10 12:21:31 -0700
commitf7a69b93c64c8e88716e5b011d4ff743b56793c1 (patch)
treeefcade89a1caa07afaf7b9ed49fe3f1dc34397cf
parent8f6e2b5485c9eea6305f6298ad0a086e5ad1bc88 (diff)
libzfsbootenv: lzbe_set_boot_device(): don't free undefined pointer
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #11993
-rw-r--r--lib/libzfsbootenv/lzbe_device.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/libzfsbootenv/lzbe_device.c b/lib/libzfsbootenv/lzbe_device.c
index b366bd9c7..2d8833b4f 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);
}
}