From: Robbie Ko Date: Tue, 17 Mar 2020 06:31:02 +0000 (+0800) Subject: btrfs: fix missing semaphore unlock in btrfs_sync_file X-Git-Tag: v5.5.18~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb9c00cfe5620ad3d427f8a335fde257aa7ace9f;p=thirdparty%2Fkernel%2Fstable.git btrfs: fix missing semaphore unlock in btrfs_sync_file commit 6ff06729c22ec0b7498d900d79cc88cfb8aceaeb upstream. Ordered ops are started twice in sync file, once outside of inode mutex and once inside, taking the dio semaphore. There was one error path missing the semaphore unlock. Fixes: aab15e8ec2576 ("Btrfs: fix rare chances for data loss when doing a fast fsync") CC: stable@vger.kernel.org # 4.19+ Signed-off-by: Robbie Ko Reviewed-by: Filipe Manana [ add changelog ] Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index abc791338d86f..4b05a506033ae 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2135,6 +2135,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) */ ret = start_ordered_ops(inode, start, end); if (ret) { + up_write(&BTRFS_I(inode)->dio_sem); inode_unlock(inode); goto out; }