Skip to content

Commit

Permalink
Fix coverity defects: CID 147602 147604
Browse files Browse the repository at this point in the history
coverity scan CID:147604, Type: Resource leak.
coverity scan CID:147602, Type: Resource leak.
reason: safe_malloc calcvs, goto children but not free calcvs.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5155
  • Loading branch information
heary-cao authored and behlendorf committed Sep 23, 2016
1 parent 7571033 commit 92bc927
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/zpool/zpool_main.c
Expand Up @@ -3382,10 +3382,12 @@ print_vdev_stats(zpool_handle_t *zhp, const char *name, nvlist_t *oldnv,
if (!(cb->cb_flags & IOS_ANYHISTO_M))
printf("\n");

free(calcvs);
ret++;

children:

free(calcvs);

if (!cb->cb_verbose)
return (ret);

Expand Down Expand Up @@ -3734,14 +3736,16 @@ static int
is_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_data)
{
iostat_cbdata_t *cb = cb_data;
char *name;
char *name = NULL;
int ret = 0;

name = zpool_vdev_name(g_zfs, zhp, nv, cb->cb_name_flags);

if (strcmp(name, cb->cb_vdev_names[0]) == 0)
return (1); /* match */
ret = 1; /* match */
free(name);

return (0);
return (ret);
}

/*
Expand Down

0 comments on commit 92bc927

Please sign in to comment.