[lkml]   [2019]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 5.0 094/238] btrfs: drop the lock on error in btrfs_dev_replace_cancel
5.0-stable review patch.  If anyone has any objections, please let me know.


From: Dan Carpenter <>

commit 669e859b5ea7c6f4fce0149d3907c64e550c294b upstream.

We should drop the lock on this error path. This has been found by a
static tool.

The lock needs to be released, it's there to protect access to the
dev_replace members and is not supposed to be left locked. The value of
state that's being switched would need to be artifically changed to an
invalid value so the default: branch is taken.

Fixes: d189dd70e255 ("btrfs: fix use-after-free due to race between replace start and cancel")
CC: # 5.0+
Reviewed-by: Anand Jain <>
Signed-off-by: Dan Carpenter <>
Reviewed-by: David Sterba <>
Signed-off-by: David Sterba <>
Signed-off-by: Greg Kroah-Hartman <>

fs/btrfs/dev-replace.c | 1 +
1 file changed, 1 insertion(+)

--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -862,6 +862,7 @@ int btrfs_dev_replace_cancel(struct btrf
+ up_write(&dev_replace->rwsem);
result = -EINVAL;

 \ /
  Last update: 2019-03-22 13:39    [W:0.521 / U:10.548 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site