From c493943404c684b5686e0e782f874448253b31c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 3 May 2021 12:13:20 +0200 Subject: [PATCH] zfs_get_enclosure_sysfs_path(): 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/libzutil/os/linux/zutil_device_path_os.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libzutil/os/linux/zutil_device_path_os.c b/lib/libzutil/os/linux/zutil_device_path_os.c index 71134a5383..2a6f4ae2a2 100644 --- a/lib/libzutil/os/linux/zutil_device_path_os.c +++ b/lib/libzutil/os/linux/zutil_device_path_os.c @@ -207,9 +207,10 @@ zfs_get_enclosure_sysfs_path(const char *dev_name) if (strstr(ep->d_name, "enclosure_device") == NULL) continue; - if (asprintf(&tmp2, "%s/%s", tmp1, ep->d_name) == -1 || - tmp2 == NULL) + if (asprintf(&tmp2, "%s/%s", tmp1, ep->d_name) == -1) { + tmp2 = NULL; break; + } size = readlink(tmp2, buf, sizeof (buf));