Skip to content

Commit

Permalink
libzfs: zpool_load_compat(): don't free undefined pointers
Browse files Browse the repository at this point in the history
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes openzfs#11993
  • Loading branch information
nabijaczleweli authored and behlendorf committed May 10, 2021
1 parent 133fd00 commit 12ed527
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/libzutil/os/linux/zutil_device_path_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,10 @@ dm_get_underlying_path(const char *dm_name)
else
dev_str = tmp;

size = asprintf(&tmp, "/sys/block/%s/slaves/", dev_str);
if (size == -1 || !tmp)
if ((size = asprintf(&tmp, "/sys/block/%s/slaves/", dev_str)) == -1) {
tmp = NULL;
goto end;
}

dp = opendir(tmp);
if (dp == NULL)
Expand All @@ -334,7 +335,9 @@ dm_get_underlying_path(const char *dm_name)
if (!enclosure_path)
continue;

size = asprintf(&path, "/dev/%s", ep->d_name);
if ((size = asprintf(
&path, "/dev/%s", ep->d_name)) == -1)
path = NULL;
free(enclosure_path);
break;
}
Expand All @@ -352,7 +355,8 @@ dm_get_underlying_path(const char *dm_name)
* enclosure devices. Throw up out hands and return the first
* underlying path.
*/
size = asprintf(&path, "/dev/%s", first_path);
if ((size = asprintf(&path, "/dev/%s", first_path)) == -1)
path = NULL;
}

free(first_path);
Expand Down

0 comments on commit 12ed527

Please sign in to comment.