From: Filipe Manana Date: Thu, 8 Jun 2023 10:27:38 +0000 (+0100) Subject: btrfs: fix extent buffer leak after tree mod log failure at split_node() X-Git-Tag: v6.6.7~2168^2~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ede600e497b1461d06d22a7d17703d9096868bc3;p=platform%2Fkernel%2Flinux-starfive.git btrfs: fix extent buffer leak after tree mod log failure at split_node() At split_node(), if we fail to log the tree mod log copy operation, we return without unlocking the split extent buffer we just allocated and without decrementing the reference we own on it. Fix this by unlocking it and decrementing the ref count before returning. Fixes: 5de865eebb83 ("Btrfs: fix tree mod logging") CC: stable@vger.kernel.org # 5.4+ Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 7f7f139..8496535 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -3053,6 +3053,8 @@ static noinline int split_node(struct btrfs_trans_handle *trans, ret = btrfs_tree_mod_log_eb_copy(split, c, 0, mid, c_nritems - mid); if (ret) { + btrfs_tree_unlock(split); + free_extent_buffer(split); btrfs_abort_transaction(trans, ret); return ret; }