]> git.ipfire.org Git - people/arne_f/kernel.git/commit
btrfs: fix extent buffer leak on failure to copy root
authorFilipe Manana <fdmanana@suse.com>
Thu, 4 Feb 2021 14:35:44 +0000 (14:35 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Mar 2021 17:22:53 +0000 (18:22 +0100)
commit335241c0d985666b25761cb98c1468613af67117
tree69d80f1f9677f878ca751d1c5938cdf75a6012ac
parent605689701f3b347f45baedec65162c2f778a4eb7
btrfs: fix extent buffer leak on failure to copy root

commit 72c9925f87c8b74f36f8e75a4cd93d964538d3ca upstream.

At btrfs_copy_root(), if the call to btrfs_inc_ref() fails we end up
returning without unlocking and releasing our reference on the extent
buffer named "cow" we previously allocated with btrfs_alloc_tree_block().

So fix that by unlocking the extent buffer and dropping our reference on
it before returning.

Fixes: be20aa9dbadc8c ("Btrfs: Add mount option to turn off data cow")
CC: stable@vger.kernel.org # 4.4+
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ctree.c