From patchwork Thu Jul 28 09:01:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Liu X-Patchwork-Id: 9250925 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 71E8D60757 for ; Thu, 28 Jul 2016 09:10:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F24C20855 for ; Thu, 28 Jul 2016 09:10:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FCE126B4A; Thu, 28 Jul 2016 09:10:26 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D70CB20855 for ; Thu, 28 Jul 2016 09:10:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bShCy-0008Cq-4f; Thu, 28 Jul 2016 09:02:24 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bShCw-0008Cd-IO for xen-devel@lists.xenproject.org; Thu, 28 Jul 2016 09:02:22 +0000 Received: from [193.109.254.147] by server-9.bemta-14.messagelabs.com id FA/24-10182-D1AC9975; Thu, 28 Jul 2016 09:02:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnkeJIrShJLcpLzFFi42LpnVTnqitzama 4wZ/dxhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a61xtYCn6xVeyZ94SlgfEraxcjF4eQQBuT RN/ednYI5wujxI3rPxkhnI2MEkd//GOGcHoZJWb8+gLUw8HBJqAkMf9+ehcjJ4eIgILE5t5nY GFmgTKJyX+FQcLCAn4SCx79ZgWxWQRUJS6f3MQEYvMKOEk8PHwDzJYQUJTofjaBDcTmFHCW2H bnMTuILQRUc3b1JRaIGkOJ0w+3MU5g5FvAyLCKUaM4tagstUjXyEQvqSgzPaMkNzEzR9fQ0EQ vN7W4ODE9NScxqVgvOT93EyMwUOoZGBh3MP685HeIUZKDSUmUNyx0ZrgQX1J+SmVGYnFGfFFp TmrxIUYZDg4lCd4jJ4BygkWp6akVaZk5wJCFSUtw8CiJ8DYdA0rzFhck5hZnpkOkTjHqciz4c XstkxBLXn5eqpQ4L+dJoCIBkKKM0jy4EbD4ucQoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmP c5yCU8mXklcJteAR3BBHREcewMkCNKEhFSUg2Mspw54jkRWXI1T2b/VWBxWbpg1o+MSzmsHyQ fP2zdl7CLn4npi8+EP+urp+2+FhoUoNGcOO2d8NqnYh4b1t+/ZXbCe/fJU0tcv3+8s9kjIUng k94x156JIbyp8b5HXcwsTUt/lZsqffhtUaXk8oGF6ZDl7BeVefxsV498djq4RPTnHfmFLcsPK rEUZyQaajEXFScCAB2qiWSaAgAA X-Env-Sender: bob.liu@oracle.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1469696539!1208109!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50135 invoked from network); 28 Jul 2016 09:02:20 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Jul 2016 09:02:20 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u6S92Dm4032463 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Jul 2016 09:02:13 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u6S92D6n000663 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Jul 2016 09:02:13 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u6S92C7h025750; Thu, 28 Jul 2016 09:02:12 GMT Received: from boliuliu.jp.oracle.com (/10.191.7.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 28 Jul 2016 02:02:11 -0700 From: Bob Liu To: linux-kernel@vger.kernel.org Date: Thu, 28 Jul 2016 17:01:44 +0800 Message-Id: <1469696505-30833-3-git-send-email-bob.liu@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1469696505-30833-1-git-send-email-bob.liu@oracle.com> References: <1469696505-30833-1-git-send-email-bob.liu@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: xen-devel@lists.xenproject.org, Bob Liu , roger.pau@citrix.com Subject: [Xen-devel] [PATCH 3/3] xen-blkfront: free resources if xlvbd_alloc_gendisk fails X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Current code forgets to free resources in the failure path of xlvbd_alloc_gendisk(), this patch fix it. Signed-off-by: Bob Liu --- drivers/block/xen-blkfront.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index d5ed60b..d8429d4 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2446,7 +2446,7 @@ static void blkfront_connect(struct blkfront_info *info) if (err) { xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", info->xbdev->otherend); - return; + goto fail; } xenbus_switch_state(info->xbdev, XenbusStateConnected); @@ -2459,6 +2459,11 @@ static void blkfront_connect(struct blkfront_info *info) add_disk(info->gd); info->is_ready = 1; + return; + +fail: + blkif_free(info, 0); + return; } /**