Skip to content

Commit 46089a2

Browse files
dioni21jsai20
authored andcommitted
Fix allocation errors, detected using ASAN
The test for VDEV_TYPE_INDIRECT is done after a memory allocation, and could return from function without freeing it. Since we don't need that allocation yet, just postpone it. Add a missing free() when buffer is no longer needed. Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: João Carlos Mendes Luís <[email protected]> Closes openzfs#10193
1 parent a9354b3 commit 46089a2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cmd/zpool/zpool_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4395,11 +4395,11 @@ print_vdev_stats(zpool_handle_t *zhp, const char *name, nvlist_t *oldnv,
43954395
uint64_t tdelta;
43964396
double scale;
43974397

4398-
calcvs = safe_malloc(sizeof (*calcvs));
4399-
44004398
if (strcmp(name, VDEV_TYPE_INDIRECT) == 0)
44014399
return (ret);
44024400

4401+
calcvs = safe_malloc(sizeof (*calcvs));
4402+
44034403
if (oldnv != NULL) {
44044404
verify(nvlist_lookup_uint64_array(oldnv,
44054405
ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&oldvs, &c) == 0);
@@ -7387,6 +7387,7 @@ print_removal_status(zpool_handle_t *zhp, pool_removal_stat_t *prs)
73877387
", (copy is slow, no estimated time)\n"));
73887388
}
73897389
}
7390+
free(vdev_name);
73907391

73917392
if (prs->prs_mapping_memory > 0) {
73927393
char mem_buf[7];

0 commit comments

Comments
 (0)