summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorcao <[email protected]>2016-12-20 02:26:15 +0800
committerBrian Behlendorf <[email protected]>2016-12-19 10:26:15 -0800
commit58bf046ab304482775355b21eacd9f9ccbf62c12 (patch)
tree2d51235285dc7840fe943c7748cd71593c712bf0 /cmd
parent6c01a4af2b5466fbdceba7304fa8b0dfb0dac839 (diff)
Fix coverity defects: CID 155008
CID 155008: Resource leaks (RESOURCE_LEAK) Reviewed-by: Giuseppe Di Natale <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Gvozden Neskovic <[email protected]> Signed-off-by: cao.xuewen <[email protected]> Closes #5500
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zpool/zpool_iter.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd/zpool/zpool_iter.c b/cmd/zpool/zpool_iter.c
index 8d8dc1731..309247b6b 100644
--- a/cmd/zpool/zpool_iter.c
+++ b/cmd/zpool/zpool_iter.c
@@ -360,6 +360,7 @@ for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl)
vdev_cmd_data_list_t *vcdl = cb_vcdl;
vdev_cmd_data_t *data;
char *path = NULL;
+ char *vname = NULL;
int i, match = 0;
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) != 0)
@@ -376,11 +377,13 @@ for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl)
/* Check for whitelisted vdevs here, if any */
for (i = 0; i < vcdl->vdev_names_count; i++) {
- if (strcmp(vcdl->vdev_names[i], zpool_vdev_name(g_zfs, zhp, nv,
- vcdl->cb_name_flags)) == 0) {
+ vname = zpool_vdev_name(g_zfs, zhp, nv, vcdl->cb_name_flags);
+ if (strcmp(vcdl->vdev_names[i], vname) == 0) {
+ free(vname);
match = 1;
break; /* match */
}
+ free(vname);
}
/* If we whitelisted vdevs, and this isn't one of them, then bail out */