Skip to content

Commit

Permalink
Fix use-after-free in btree code
Browse files Browse the repository at this point in the history
Coverty static analysis found these.

Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Neal Gompa <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes openzfs#10989
Closes openzfs#13861
(cherry picked from commit 13f2b8f)
  • Loading branch information
ryao authored and geoffamey committed Jul 5, 2023
1 parent 2f327a2 commit 18ae267
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/zfs/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,8 +1536,8 @@ zfs_btree_remove_from_node(zfs_btree_t *tree, zfs_btree_core_t *node,
zfs_btree_poison_node_at(tree, keep_hdr, keep_hdr->bth_count);

new_rm_hdr->bth_count = 0;
zfs_btree_node_destroy(tree, new_rm_hdr);
zfs_btree_remove_from_node(tree, parent, new_rm_hdr);
zfs_btree_node_destroy(tree, new_rm_hdr);
}

/* Remove the element at the specific location. */
Expand Down Expand Up @@ -1769,6 +1769,7 @@ zfs_btree_remove_idx(zfs_btree_t *tree, zfs_btree_index_t *where)
zfs_btree_node_destroy(tree, rm_hdr);
/* Remove the emptied node from the parent. */
zfs_btree_remove_from_node(tree, parent, rm_hdr);
zfs_btree_node_destroy(tree, rm_hdr);
zfs_btree_verify(tree);
}

Expand Down

0 comments on commit 18ae267

Please sign in to comment.