Skip to content

Commit 12ed527

Browse files
nabijaczlewelibehlendorf
authored andcommitted
libzfs: zpool_load_compat(): don't free undefined pointers
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes openzfs#11993
1 parent 133fd00 commit 12ed527

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/libzutil/os/linux/zutil_device_path_os.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,10 @@ dm_get_underlying_path(const char *dm_name)
306306
else
307307
dev_str = tmp;
308308

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

313314
dp = opendir(tmp);
314315
if (dp == NULL)
@@ -334,7 +335,9 @@ dm_get_underlying_path(const char *dm_name)
334335
if (!enclosure_path)
335336
continue;
336337

337-
size = asprintf(&path, "/dev/%s", ep->d_name);
338+
if ((size = asprintf(
339+
&path, "/dev/%s", ep->d_name)) == -1)
340+
path = NULL;
338341
free(enclosure_path);
339342
break;
340343
}
@@ -352,7 +355,8 @@ dm_get_underlying_path(const char *dm_name)
352355
* enclosure devices. Throw up out hands and return the first
353356
* underlying path.
354357
*/
355-
size = asprintf(&path, "/dev/%s", first_path);
358+
if ((size = asprintf(&path, "/dev/%s", first_path)) == -1)
359+
path = NULL;
356360
}
357361

358362
free(first_path);

0 commit comments

Comments
 (0)