From patchwork Fri Oct 13 02:16:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 10003405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4420560216 for ; Fri, 13 Oct 2017 02:18:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29FC128D9B for ; Fri, 13 Oct 2017 02:18:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E17728D99; Fri, 13 Oct 2017 02:18:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A0D628D99 for ; Fri, 13 Oct 2017 02:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753291AbdJMCSR (ORCPT ); Thu, 12 Oct 2017 22:18:17 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:31948 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751657AbdJMCSQ (ORCPT ); Thu, 12 Oct 2017 22:18:16 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9D2HCLI008924 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Oct 2017 02:17:13 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v9D2HC99030736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Oct 2017 02:17:12 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v9D2HCI2023008; Fri, 13 Oct 2017 02:17:12 GMT Received: from localhost.localdomain (/42.60.24.64) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Oct 2017 19:17:11 -0700 From: Anand Jain 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 Message-Id: <20171013021654.14461-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20171012203900.dqdsfcpbfjyl7bea@mwanda> References: <20171012203900.dqdsfcpbfjyl7bea@mwanda> X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In btrfs_init_new_device() when btrfs_attach_transaction() fails we shouldn't call btrfs_end_transaction(). Fix it. Signed-off-by: Anand Jain 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: