diff options
author | наб <[email protected]> | 2021-04-30 20:49:39 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2021-05-10 12:21:06 -0700 |
commit | 12ed5275d138123b5c67e90494bde213b78337cc (patch) | |
tree | 35ff68ef92659b3f1682b799fe0545816003f39d | |
parent | 133fd00930ed99e3549f87cecea4117109016b3d (diff) |
libzfs: zpool_load_compat(): don't free undefined pointers
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #11993
-rw-r--r-- | lib/libzutil/os/linux/zutil_device_path_os.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libzutil/os/linux/zutil_device_path_os.c b/lib/libzutil/os/linux/zutil_device_path_os.c index da7ffba76..dae5b8971 100644 --- a/lib/libzutil/os/linux/zutil_device_path_os.c +++ b/lib/libzutil/os/linux/zutil_device_path_os.c @@ -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) @@ -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; } @@ -352,7 +355,8 @@ end: * 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); |