btrfs: fix call to btrfs_end_transaction without a transaction handler
diff mbox

Message ID 20171013021654.14461-1-anand.jain@oracle.com
State New
Headers show

Commit Message

Anand Jain Oct. 13, 2017, 2:16 a.m. UTC
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.jain@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(-)

Comments

David Sterba Oct. 16, 2017, 2:07 p.m. UTC | #1
On Fri, Oct 13, 2017 at 10:16:54AM +0800, Anand Jain wrote:
> 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.jain@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.

I have squashed the incremental change, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

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: