btrfs: sync ioctl, handle errors after transaction start
authorDavid Sterba <dsterba@suse.cz>
Mon, 19 Jan 2015 13:21:02 +0000 (14:21 +0100)
committerChris Mason <clm@fb.com>
Mon, 19 Jan 2015 21:05:44 +0000 (13:05 -0800)
The version merged to 3.19 did not handle errors from start_trancaction
and could pass an invalid pointer to commit_transaction.

Fixes: 6b5fe46dfa52441f ("btrfs: do commit in sync_fs if there are pending changes")
Reported-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/super.c

index 60f7cbe815e9c88362a1680f8e4259f51ca6f019..c86fb5438454481869e6a1199929836da1ab8b4a 100644 (file)
@@ -1001,9 +1001,9 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
                        if (fs_info->pending_changes == 0)
                                return 0;
                        trans = btrfs_start_transaction(root, 0);
-               } else {
-                       return PTR_ERR(trans);
                }
+               if (IS_ERR(trans))
+                       return PTR_ERR(trans);
        }
        return btrfs_commit_transaction(trans, root);
 }