]> granicus.if.org Git - zfs/commitdiff
Fix traverse_impl() kmem leak
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 15 Aug 2018 16:53:44 +0000 (09:53 -0700)
committerGitHub <noreply@github.com>
Wed, 15 Aug 2018 16:53:44 +0000 (09:53 -0700)
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 <guss80@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #7791

module/zfs/dmu_traverse.c

index f0b5356180a871b7fbfb3f2e54ed133551899351..f4265209918ec4faa808ecd4966195bbd01c001d 100644 (file)
@@ -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);