kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix double unlock bugs in btrfs_compare_trees()
@ 2022-01-07  7:24 Dan Carpenter
  2022-01-07 10:26 ` Filipe Manana
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2022-01-07  7:24 UTC (permalink / raw)
  To: Chris Mason, Filipe Manana
  Cc: Josef Bacik, David Sterba, linux-btrfs, kernel-janitors

These error paths unlock before the goto, but the goto also unlocks
so it's a double unlock.

Fixes: 5646ffa863d0 ("btrfs: make send work with concurrent block group relocation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/btrfs/send.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 3fc144b8c0d8..1aa8a0998673 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -7152,7 +7152,6 @@ static int btrfs_compare_trees(struct btrfs_root *left_root,
 	left_path->nodes[left_level] =
 			btrfs_clone_extent_buffer(left_root->commit_root);
 	if (!left_path->nodes[left_level]) {
-		up_read(&fs_info->commit_root_sem);
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -7162,7 +7161,6 @@ static int btrfs_compare_trees(struct btrfs_root *left_root,
 	right_path->nodes[right_level] =
 			btrfs_clone_extent_buffer(right_root->commit_root);
 	if (!right_path->nodes[right_level]) {
-		up_read(&fs_info->commit_root_sem);
 		ret = -ENOMEM;
 		goto out;
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: fix double unlock bugs in btrfs_compare_trees()
  2022-01-07  7:24 [PATCH] btrfs: fix double unlock bugs in btrfs_compare_trees() Dan Carpenter
@ 2022-01-07 10:26 ` Filipe Manana
  2022-01-07 10:38   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Filipe Manana @ 2022-01-07 10:26 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Chris Mason, Filipe Manana, Josef Bacik, David Sterba,
	linux-btrfs, kernel-janitors

On Fri, Jan 07, 2022 at 10:24:30AM +0300, Dan Carpenter wrote:
> These error paths unlock before the goto, but the goto also unlocks
> so it's a double unlock.

There's also the case where there's an unlock without a previous lock.
I've just sent out a different version of the patch that fixes that as well:

https://lore.kernel.org/linux-btrfs/a7b1b2094bb0697dda72bdd9bf1ed789cb0b9b08.1641550850.git.fdmanana@suse.com/

Thanks.

> 
> Fixes: 5646ffa863d0 ("btrfs: make send work with concurrent block group relocation")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  fs/btrfs/send.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 3fc144b8c0d8..1aa8a0998673 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -7152,7 +7152,6 @@ static int btrfs_compare_trees(struct btrfs_root *left_root,
>  	left_path->nodes[left_level] =
>  			btrfs_clone_extent_buffer(left_root->commit_root);
>  	if (!left_path->nodes[left_level]) {
> -		up_read(&fs_info->commit_root_sem);
>  		ret = -ENOMEM;
>  		goto out;
>  	}
> @@ -7162,7 +7161,6 @@ static int btrfs_compare_trees(struct btrfs_root *left_root,
>  	right_path->nodes[right_level] =
>  			btrfs_clone_extent_buffer(right_root->commit_root);
>  	if (!right_path->nodes[right_level]) {
> -		up_read(&fs_info->commit_root_sem);
>  		ret = -ENOMEM;
>  		goto out;
>  	}
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: fix double unlock bugs in btrfs_compare_trees()
  2022-01-07 10:26 ` Filipe Manana
@ 2022-01-07 10:38   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-01-07 10:38 UTC (permalink / raw)
  To: Filipe Manana
  Cc: Chris Mason, Filipe Manana, Josef Bacik, David Sterba,
	linux-btrfs, kernel-janitors

On Fri, Jan 07, 2022 at 10:26:33AM +0000, Filipe Manana wrote:
> On Fri, Jan 07, 2022 at 10:24:30AM +0300, Dan Carpenter wrote:
> > These error paths unlock before the goto, but the goto also unlocks
> > so it's a double unlock.
> 
> There's also the case where there's an unlock without a previous lock.
> I've just sent out a different version of the patch that fixes that as well:
> 
> https://lore.kernel.org/linux-btrfs/a7b1b2094bb0697dda72bdd9bf1ed789cb0b9b08.1641550850.git.fdmanana@suse.com/ 

Ah! Thanks.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-07 10:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-07  7:24 [PATCH] btrfs: fix double unlock bugs in btrfs_compare_trees() Dan Carpenter
2022-01-07 10:26 ` Filipe Manana
2022-01-07 10:38   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).