From patchwork Thu Dec 21 21:54:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Azhar Shaikh X-Patchwork-Id: 10128449 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 5C93760318 for ; Thu, 21 Dec 2017 21:54:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 501DD2465D for ; Thu, 21 Dec 2017 21:54:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44E9029EA2; Thu, 21 Dec 2017 21:54:41 +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 autolearn=unavailable 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 EE0402465D for ; Thu, 21 Dec 2017 21:54:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751057AbdLUVyj convert rfc822-to-8bit (ORCPT ); Thu, 21 Dec 2017 16:54:39 -0500 Received: from mga03.intel.com ([134.134.136.65]:46047 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbdLUVyi (ORCPT ); Thu, 21 Dec 2017 16:54:38 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Dec 2017 13:54:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,437,1508828400"; d="scan'208";a="14674639" Received: from orsmsx110.amr.corp.intel.com ([10.22.240.8]) by fmsmga004.fm.intel.com with ESMTP; 21 Dec 2017 13:54:36 -0800 Received: from orsmsx109.amr.corp.intel.com ([169.254.11.160]) by ORSMSX110.amr.corp.intel.com ([169.254.10.149]) with mapi id 14.03.0319.002; Thu, 21 Dec 2017 13:54:27 -0800 From: "Shaikh, Azhar" To: Jason Gunthorpe CC: "jarkko.sakkinen@linux.intel.com" , "javierm@redhat.com" , "peterhuewe@gmx.de" , "linux-security-module@vger.kernel.org" , "linux-integrity@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "tpmdd-devel@lists.sourceforge.net" Subject: RE: [PATCH] tpm: Fix the driver cleanup code Thread-Topic: [PATCH] tpm: Fix the driver cleanup code Thread-Index: AQHTepoOkKvxqwDV30CBEJrcFFLGoqNOP2HQgACI9ID//44s4A== Date: Thu, 21 Dec 2017 21:54:26 +0000 Message-ID: <5FFFAD06ADE1CA4381B3F0F7C6AF582898918B@ORSMSX109.amr.corp.intel.com> References: <1513887422-123222-1-git-send-email-azhar.shaikh@intel.com> <20171221202652.GH20015@ziepe.ca> <5FFFAD06ADE1CA4381B3F0F7C6AF5828989144@ORSMSX109.amr.corp.intel.com> <20171221203853.GI20015@ziepe.ca> In-Reply-To: <20171221203853.GI20015@ziepe.ca> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMWM2OTNiM2ItYzI5Ny00ZTczLTlhNzUtYWRhZGViYmJjNmZkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJSSTc0a3ZXR1QrUjVLMm5PUTQ0SDM2MkRtR3JaenpuWldQS0t5cmdWVFNTVGhSUFJEZTFWQUY1czBpcE5iYjB5In0= dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP >-----Original Message----- >From: linux-integrity-owner@vger.kernel.org [mailto:linux-integrity- >owner@vger.kernel.org] On Behalf Of Jason Gunthorpe >Sent: Thursday, December 21, 2017 12:39 PM >To: Shaikh, Azhar >Cc: jarkko.sakkinen@linux.intel.com; javierm@redhat.com; >peterhuewe@gmx.de; linux-security-module@vger.kernel.org; linux- >integrity@vger.kernel.org; linux-kernel@vger.kernel.org; tpmdd- >devel@lists.sourceforge.net >Subject: Re: [PATCH] tpm: Fix the driver cleanup code > >On Thu, Dec 21, 2017 at 08:31:14PM +0000, Shaikh, Azhar wrote: > >> Yes I thought about it too. But if some other chip->ops function in >> future, which *might* be in this same case, hence for that introduced >> this flag. > >It can't be - the ops struct is constant, can't be modified, and tpm_tis_core >controls what is set. If someone future person meddles in this then they can >fix here to. > Yes, I checked this part. What I was referring to is any other callback function similar to clk_enable if gets added in future and then needs to Access ops even after it is set to NULL... >Recommend a short comment in the ops clk_enale initializer and call direct? > But yes I get your point now. So do you mean something like this? >Jason Regards, Azhar Shaikh --- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index d9099281fc2e..1187e72483f2 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -716,8 +716,7 @@ void tpm_tis_remove(struct tpm_chip *chip) u32 interrupt; int rc; - if (chip->ops->clk_enable != NULL) - chip->ops->clk_enable(chip, true); + tpm_tis_clkrun_enable(chip, true); rc = tpm_tis_read32(priv, reg, &interrupt); if (rc < 0) @@ -725,14 +724,8 @@ void tpm_tis_remove(struct tpm_chip *chip) tpm_tis_write32(priv, reg, ~TPM_GLOBAL_INT_ENABLE & interrupt); - if (chip->ops->clk_enable != NULL) - chip->ops->clk_enable(chip, false); + tpm_tis_clkrun_enable(chip, false); - if (chip->flags & TPM_CHIP_FLAG_DO_NOT_CLEAR_OPS) { - down_write(&chip->ops_sem); - chip->ops = NULL; - up_write(&chip->ops_sem); - } if (priv->ilb_base_addr) iounmap(priv->ilb_base_addr); }