summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2018-08-15 09:53:44 -0700
committerGitHub <[email protected]>2018-08-15 09:53:44 -0700
commit4338c5c06fbe92fdef9a5f0f7e457fae98c94b4d (patch)
treed2711cd65c7da85cf965c858b11df14b2f28b123
parent1dfde3d9b20b3be24a0cb24520652c22bbeb7499 (diff)
Fix traverse_impl() kmem leak
The error path must free the memory allocated by this function or it will be leaked. In practice, this would leak only a few bytes of memory under rare circumstances and thus is unlikely to have caused any real problems. This issue was caught by the kmemleak. Reviewed-by: Giuseppe Di Natale <[email protected]> Reviewed-by: George Melikov <[email protected]> Reviewed-by: Chunwei Chen <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #7791
-rw-r--r--module/zfs/dmu_traverse.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/module/zfs/dmu_traverse.c b/module/zfs/dmu_traverse.c
index f0b535618..f42652099 100644
--- a/module/zfs/dmu_traverse.c
+++ b/module/zfs/dmu_traverse.c
@@ -650,7 +650,7 @@ traverse_impl(spa_t *spa, dsl_dataset_t *ds, uint64_t objset, blkptr_t *rootbp,
*/
if (!(td->td_flags & TRAVERSE_HARD) ||
!(td->td_flags & TRAVERSE_PRE))
- return (err);
+ goto out;
} else {
osp = buf->b_data;
traverse_zil(td, &osp->os_zil_header);
@@ -671,7 +671,7 @@ traverse_impl(spa_t *spa, dsl_dataset_t *ds, uint64_t objset, blkptr_t *rootbp,
while (!pd->pd_exited)
cv_wait_sig(&pd->pd_cv, &pd->pd_mtx);
mutex_exit(&pd->pd_mtx);
-
+out:
mutex_destroy(&pd->pd_mtx);
cv_destroy(&pd->pd_cv);