zfs_get_enclosure_sysfs_path(): 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:13:20 +02:00 committed by Brian Behlendorf
parent 14b56624c8
commit 8f6e2b5485
1 changed files with 3 additions and 2 deletions

View File

@ -207,9 +207,10 @@ zfs_get_enclosure_sysfs_path(const char *dev_name)
if (strstr(ep->d_name, "enclosure_device") == NULL) if (strstr(ep->d_name, "enclosure_device") == NULL)
continue; continue;
if (asprintf(&tmp2, "%s/%s", tmp1, ep->d_name) == -1 || if (asprintf(&tmp2, "%s/%s", tmp1, ep->d_name) == -1) {
tmp2 == NULL) tmp2 = NULL;
break; break;
}
size = readlink(tmp2, buf, sizeof (buf)); size = readlink(tmp2, buf, sizeof (buf));