diff --git a/lib/libzutil/os/linux/zutil_device_path_os.c b/lib/libzutil/os/linux/zutil_device_path_os.c index 1f767bb7a6..66b9d52b92 100644 --- a/lib/libzutil/os/linux/zutil_device_path_os.c +++ b/lib/libzutil/os/linux/zutil_device_path_os.c @@ -195,10 +195,8 @@ zfs_get_enclosure_sysfs_path(const char *dev_name) } dp = opendir(tmp1); - if (dp == NULL) { - tmp1 = NULL; /* To make free() at the end a NOP */ + if (dp == NULL) goto end; - } /* * Look though all sysfs entries in /sys/block//device for @@ -216,11 +214,8 @@ zfs_get_enclosure_sysfs_path(const char *dev_name) size = readlink(tmp2, buf, sizeof (buf)); /* Did readlink fail or crop the link name? */ - if (size == -1 || size >= sizeof (buf)) { - free(tmp2); - tmp2 = NULL; /* To make free() at the end a NOP */ + if (size == -1 || size >= sizeof (buf)) break; - } /* * We got a valid link. readlink() doesn't terminate strings