summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoao Carlos Mendes Luis <[email protected]>2020-04-13 14:54:41 -0300
committerGitHub <[email protected]>2020-04-13 10:54:41 -0700
commit75c62019f3938e7bc81becb4fb2d5b5eb523e79a (patch)
treed0560a68a02f7c3e5436d3edf75c7a91b75ff100
parent791e480c6ac7a3e33adc5270b3fc99015f9f0c15 (diff)
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 #10193
-rw-r--r--cmd/zpool/zpool_main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index b5f2f9b02..e8e94cd94 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -4395,11 +4395,11 @@ print_vdev_stats(zpool_handle_t *zhp, const char *name, nvlist_t *oldnv,
uint64_t tdelta;
double scale;
- calcvs = safe_malloc(sizeof (*calcvs));
-
if (strcmp(name, VDEV_TYPE_INDIRECT) == 0)
return (ret);
+ calcvs = safe_malloc(sizeof (*calcvs));
+
if (oldnv != NULL) {
verify(nvlist_lookup_uint64_array(oldnv,
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)
", (copy is slow, no estimated time)\n"));
}
}
+ free(vdev_name);
if (prs->prs_mapping_memory > 0) {
char mem_buf[7];