diff options
author | Brian Behlendorf <[email protected]> | 2022-06-20 21:35:38 +0000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-06-27 14:19:24 -0700 |
commit | c175f5ebb2f4910e2d4f38f794e3973e53baa94e (patch) | |
tree | a47671978868eaabe5ff427ce5876586dd7df391 | |
parent | 9619bcdefb0dff38e36f8c89d9e2980112105cbb (diff) |
Fix -Wuse-after-free warning in dbuf_destroy()
Move the use of the db pointer after it is freed. It's only used as
a tag so a dereference would never occur, but there's no reason we
can't invert the order to resolve the warning.
module/zfs/dbuf.c: In function 'dbuf_destroy':
module/zfs/dbuf.c:2953:17: error:
pointer 'db' may be used after 'free' [-Werror=use-after-free]
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #13528
Closes #13575
-rw-r--r-- | module/zfs/dbuf.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index 71b2b0992..d10e87652 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -2941,9 +2941,6 @@ dbuf_destroy(dmu_buf_impl_t *db) ASSERT3U(db->db_caching_status, ==, DB_NO_CACHE); ASSERT(!multilist_link_active(&db->db_cache_link)); - kmem_cache_free(dbuf_kmem_cache, db); - arc_space_return(sizeof (dmu_buf_impl_t), ARC_SPACE_DBUF); - /* * If this dbuf is referenced from an indirect dbuf, * decrement the ref count on the indirect dbuf. @@ -2952,6 +2949,9 @@ dbuf_destroy(dmu_buf_impl_t *db) mutex_enter(&parent->db_mtx); dbuf_rele_and_unlock(parent, db, B_TRUE); } + + kmem_cache_free(dbuf_kmem_cache, db); + arc_space_return(sizeof (dmu_buf_impl_t), ARC_SPACE_DBUF); } /* |