linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.com
Subject: [PATCH] btrfs: fix call to btrfs_end_transaction without a transaction handler
Date: Fri, 13 Oct 2017 10:16:54 +0800	[thread overview]
Message-ID: <20171013021654.14461-1-anand.jain@oracle.com> (raw)
In-Reply-To: <20171012203900.dqdsfcpbfjyl7bea@mwanda>

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(-)

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


  parent reply	other threads:[~2017-10-13  2:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12 20:39 [bug report] btrfs: error out if btrfs_attach_transaction() fails Dan Carpenter
2017-10-13  1:59 ` Anand Jain
2017-10-13  2:16 ` Anand Jain [this message]
2017-10-16 14:07   ` [PATCH] btrfs: fix call to btrfs_end_transaction without a transaction handler David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171013021654.14461-1-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).