In btrfs_init_new_device() when btrfs_attach_transaction() fails we
shouldn't call btrfs_end_transaction(). Fix it.

Signed-off-by: Anand Jain <anand.j...@oracle.com>
Fixes:
  btrfs: error out if btrfs_attach_transaction() fails
---
Hi David,
  Can you pls squash this changes to the patch which it
  fixes. OR if its better to send the original the with
  the fix, pls let me know I will do it.
Thanks.

 fs/btrfs/volumes.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 90805581ea10..efd502176915 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2477,6 +2477,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, 
const char *device_path
                        if (PTR_ERR(trans) == -ENOENT)
                                return 0;
                        ret = PTR_ERR(trans);
+                       trans = NULL;
                        goto error_sysfs;
                }
                ret = btrfs_commit_transaction(trans);
@@ -2491,7 +2492,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, 
const char *device_path
 error_trans:
        if (seeding_dev)
                sb->s_flags |= MS_RDONLY;
-       btrfs_end_transaction(trans);
+       if (trans)
+               btrfs_end_transaction(trans);
        rcu_string_free(device->name);
        kfree(device);
 error:
-- 
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to