Skip to content

Commit 2deb68e

Browse files
committed
Memory fixes
Signed-off-by: Richard Yao <ryao@gentoo.org>
1 parent bdfc4b8 commit 2deb68e

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

cmd/zfs/zfs_iter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ zfs_callback(zfs_handle_t *zhp, void *data)
9595
boolean_t dontclose = B_FALSE;
9696
boolean_t include_snaps = zfs_include_snapshots(zhp, cb);
9797

98+
zhp = zfs_handle_dup(zhp);
99+
98100
if ((zfs_get_type(zhp) & cb->cb_types) ||
99101
((zfs_get_type(zhp) == ZFS_TYPE_SNAPSHOT) && include_snaps)) {
100102
uu_avl_index_t idx;
@@ -447,6 +449,7 @@ zfs_for_each(int argc, char **argv, int flags, zfs_type_t types,
447449
limit_specified, zfs_callback, &cb);
448450
else
449451
ret = 1;
452+
zfs_close(zhp);
450453
}
451454
}
452455

lib/libzfs/libzfs_iter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ zfs_iter_cb(nvlist_t *nvl, void *data)
145145

146146
ret = (*cb->zicb_func)(nzhp, cb->zicb_data);
147147

148+
zfs_close(nzhp);
149+
148150
return (ret);
149151
}
150152

0 commit comments

Comments
 (0)