From patchwork Tue May 30 21:51:23 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: 9760923 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 B33E76038E for ; Thu, 1 Jun 2017 19:20:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A265D284F9 for ; Thu, 1 Jun 2017 19:20:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 973B1284FE; Thu, 1 Jun 2017 19:20:07 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 48F7C2850E for ; Thu, 1 Jun 2017 19:20:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1dGVdZ-0003WP-Ap; Thu, 01 Jun 2017 19:20:01 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1dFp36-00025c-Nb for tpmdd-devel@lists.sourceforge.net; Tue, 30 May 2017 21:51:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:Message-ID:Subject:Cc:To:From:Date; bh=wV6qHKYhHENQgVi6666GRcFZKxNbTbJUrguBKeFhZlo=; b=NK7Jp0uxtrKAZddOWPme6/1NmO5alzTWx3g9GIllL2Zo8HMVrNEF0XHhV5lAtP1HmrCUQ50sK+7ORt/yOusi/iykTFFE5jmzGReYK8YWprfiQ40py9RzXiXFzhC6TiPZ7QPoAWUeKUB9lhtUHq6xNoCTrlHVE9CpqPwE09zYOBU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x; h=Content-Type:MIME-Version:Message-ID:Subject:Cc:To:From:Date; bh=wV6qHKYhHENQgVi6666GRcFZKxNbTbJUrguBKeFhZlo=; b=EpmHeMlC6HFMYTdCPSI/5dP5MZp3FBQuZMITapeiPZvYRdxdHjfEYzN5QF3yQzremz8LugpKTWQ/xxp1VOtQ0f+OEnSDqlSli7O7POo/W6jXyDz9F6TbyF/xMYu326ZNC3hSPgPD1j5RTH8DZ8mXoWTj1W+YyjurkBtAHX/0ilw=; Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of embeddedor.com designates 192.185.47.79 as permitted sender) client-ip=192.185.47.79; envelope-from=garsilva@embeddedor.com; helo=gateway22.websitewelcome.com; Received: from gateway22.websitewelcome.com ([192.185.47.79]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1dFp34-00072b-LK for tpmdd-devel@lists.sourceforge.net; Tue, 30 May 2017 21:51:32 +0000 Received: from cm1.websitewelcome.com (cm.websitewelcome.com [192.185.0.102]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 2E86555B49 for ; Tue, 30 May 2017 16:51:25 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cm1.websitewelcome.com with id SlrQ1v0070V9LXg01lrRte; Tue, 30 May 2017 16:51:25 -0500 Received: from [189.152.214.95] (port=58754 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.87) (envelope-from ) id 1dFp2x-000WKC-RD; Tue, 30 May 2017 16:51:23 -0500 Date: Tue, 30 May 2017 16:51:23 -0500 From: "Gustavo A. R. Silva" To: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , Jason Gunthorpe Message-ID: <20170530215123.GA7484@embeddedgus> MIME-Version: 1.0 Content-Disposition: inline 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.sourceforge.net 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.214.95 X-Exim-ID: 1dFp2x-000WKC-RD X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.152.214.95]:58754 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 7 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Headers-End: 1dFp34-00072b-LK X-Mailman-Approved-At: Thu, 01 Jun 2017 19:19:58 +0000 Subject: [tpmdd-devel] [PATCH] char: tmp: fix potential null pointer dereference X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tpmdd-devel@lists.sourceforge.net, "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP NULL check at line 147: if (chip) {, implies chip might be NULL. Function dev_get_drvdata() dereference pointer chip. Move pointer priv assignment inside the IF block that checks pointer chip. Addresses-Coverity-ID: 1397646 Signed-off-by: Gustavo A. R. Silva --- drivers/char/tpm/tpm_atmel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c index 0d322ab..0826efd 100644 --- a/drivers/char/tpm/tpm_atmel.c +++ b/drivers/char/tpm/tpm_atmel.c @@ -142,9 +142,10 @@ static struct platform_device *pdev; static void atml_plat_remove(void) { struct tpm_chip *chip = dev_get_drvdata(&pdev->dev); - struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev); + struct tpm_atmel_priv *priv; if (chip) { + priv = dev_get_drvdata(&chip->dev); tpm_chip_unregister(chip); if (priv->have_region) atmel_release_region(priv->base, priv->region_size);