Btrfs: don't leak transaction in btrfs_sync_file()
authorFilipe David Borba Manana <fdmanana@gmail.com>
Wed, 11 Sep 2013 19:36:44 +0000 (20:36 +0100)
committerChris Mason <chris.mason@fusionio.com>
Sat, 21 Sep 2013 15:05:29 +0000 (11:05 -0400)
In btrfs_sync_file(), if the call to btrfs_log_dentry_safe() returns
a negative error (for e.g. -ENOMEM via btrfs_log_inode()), we would
return without ending/freeing the transaction.

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/file.c

index 5ba87b0d2ef86d1563705df7ae62f48e59b7cbae..d12107e909870165ae68bc889ae7bac14a7a96ee 100644 (file)
@@ -1859,8 +1859,8 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 
        ret = btrfs_log_dentry_safe(trans, root, dentry);
        if (ret < 0) {
-               mutex_unlock(&inode->i_mutex);
-               goto out;
+               /* Fallthrough and commit/free transaction. */
+               ret = 1;
        }
 
        /* we've logged all the items and now have a consistent