From patchwork Thu May 11 15:27:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 9722173 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 E2E5F6031B for ; Thu, 11 May 2017 15:29:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9D982869A for ; Thu, 11 May 2017 15:29:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D182286AC; Thu, 11 May 2017 15:29:57 +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 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 76C382869A for ; Thu, 11 May 2017 15:29:56 +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 1d8q0E-00058x-VF; Thu, 11 May 2017 15:27:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8q0D-00058r-AZ for xen-devel@lists.xenproject.org; Thu, 11 May 2017 15:27:41 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 7A/69-03696-CE284195; Thu, 11 May 2017 15:27:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMKsWRWlGSWpSXmKPExsVyYOeE27qvm0Q iDU7u0LP4vmUykwOjx+EPV1gCGKNYM/OS8isSWDO63kxiK1jDXnFk5j/WBsYNbF2MXBxCAhcY JS6ue8cM4UxjlFjVvIsFwrnEKHF+eTNQhpODRUBVYs+Ez0A2BwebgKnE+Q2mIDUiAhMYJTquf WICqWEWKJL4/GE7mC0sECax+ftzFhCbV0Bf4uHLe8wQtqDEyZlPWCDqtSRu/HvJBDKTWUBaYv k/DpAwp0CwROuLjWDlogIqElcmvGUHsSUEoiT+7r7KAmGbS7yadZINwjaWePlqATOEbSXx+/A aFph449r/UL0CEm1/TrJC2NIS72fvYYOx/y3aC9XLJXFg6jyoOL/E4dn3GCFsPol9C0GhxQFk m0qs+MsJEVaT2LxjHivM+KuzrkDZbhI3Hn5kmsAoOwvJw7OQPDwL4eEFjMyrGDWKU4vKUot0j Yz0kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECo5oBCHYwrpkfeIhRkoNJSZS3/Y 9wpBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3puNIpFCgkWp6akVaZk5wPQCk5bg4FES4d1VD5T mLS5IzC3OTIdInWI05phz7+t7Jo4Xt3+8ZxJiycvPS5US5z0NMkkApDSjNA9uECztXWKUlRLm ZQQ6TYinILUoN7MEVf4VozgHo5Iw7wqQKTyZeSVw+14BncIEdEo/yBe8xSWJCCmpBkbO6mk/T s1+o9f7L4EhfVJo7lkZXY1tGcqde1PnX5u+T+fDbanQ/eYiF5u+SDb0v3DUSlrAkKK2RfSl/P KzSt3nvHnuXrGe6FxRx6wXcIy5KmbGYeMLu9U8LOy1uFfXKl1ObX+lf7ApXn76RvGp/t1PsnM /Zn1RXpOeu/DkadfOHS1ss3v0VyuxFGckGmoxFxUnAgC9aSVqdgMAAA== X-Env-Sender: garsilva@embeddedor.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1494516458!67848445!1 X-Originating-IP: [192.185.144.219] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22053 invoked from network); 11 May 2017 15:27:39 -0000 Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.144.219) by server-9.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 May 2017 15:27:39 -0000 Received: from cm1.websitewelcome.com (unknown [192.185.0.102]) by gateway31.websitewelcome.com (Postfix) with ESMTP id AFB37D778C for ; Thu, 11 May 2017 10:27:37 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cm1.websitewelcome.com with id K3Tc1v00u0V9LXg013Tdzx; Thu, 11 May 2017 10:27:37 -0500 Received: from [189.152.186.83] (port=40706 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.87) (envelope-from ) id 1d8q08-0002IY-9n; Thu, 11 May 2017 10:27:36 -0500 Date: Thu, 11 May 2017 10:27:35 -0500 From: "Gustavo A. R. Silva" To: Konrad Rzeszutek Wilk , Roger Pau =?iso-8859-1?Q?Monn=E9?= , Juergen Gross Message-ID: <20170511152735.GA4409@embeddedgus> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170511100544.Horde.88c0RhMPEXYq42BauaUXfHV@gator4166.hostgator.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - lists.xenproject.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.152.186.83 X-Exim-ID: 1d8q08-0002IY-9n X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.152.186.83]:40706 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 9 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= Cc: xen-devel@lists.xenproject.org, "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH] block: xen-blkback: add null check to avoid null pointer dereference 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add null check before calling xen_blkif_put() to avoid potential null pointer dereference. Addresses-Coverity-ID: 1350942 Cc: Juergen Gross Signed-off-by: Gustavo A. R. Silva --- drivers/block/xen-blkback/xenbus.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index 8fe61b5..1f3dfaa 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -504,11 +504,13 @@ static int xen_blkbk_remove(struct xenbus_device *dev) dev_set_drvdata(&dev->dev, NULL); - if (be->blkif) + if (be->blkif) { xen_blkif_disconnect(be->blkif); - /* Put the reference we set in xen_blkif_alloc(). */ - xen_blkif_put(be->blkif); + /* Put the reference we set in xen_blkif_alloc(). */ + xen_blkif_put(be->blkif); + } + kfree(be->mode); kfree(be); return 0;