From 87b671f3ace5ab47fd5449279374051cfd8856b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 3 May 2021 12:11:30 +0200 Subject: [PATCH] libzfsbootenv: lzbe_set_boot_device(): don't free undefined pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Closes #11993 --- lib/libzfsbootenv/lzbe_device.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/libzfsbootenv/lzbe_device.c b/lib/libzfsbootenv/lzbe_device.c index b366bd9c7f57..2d8833b4fff2 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); } }