From patchwork Wed Oct 10 13:38:17 2018 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: 10634613 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88D815CAF for ; Wed, 10 Oct 2018 14:01:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E55502A2ED for ; Wed, 10 Oct 2018 14:01:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E36082A375; Wed, 10 Oct 2018 14:01:13 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 59FA52A30E for ; Wed, 10 Oct 2018 14:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726649AbeJJVXb (ORCPT ); Wed, 10 Oct 2018 17:23:31 -0400 Received: from gateway21.websitewelcome.com ([192.185.45.133]:33986 "EHLO gateway21.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbeJJVXb (ORCPT ); Wed, 10 Oct 2018 17:23:31 -0400 X-Greylist: delayed 1356 seconds by postgrey-1.27 at vger.kernel.org; Wed, 10 Oct 2018 17:23:30 EDT Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway21.websitewelcome.com (Postfix) with ESMTP id BC784400DEBB4 for ; Wed, 10 Oct 2018 08:38:41 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id AEgugAgGz8YaUAEh7gcHxQ; Wed, 10 Oct 2018 08:38:41 -0500 X-Authority-Reason: nr=8 Received: from 57.154.24.109.rev.sfr.net ([109.24.154.57]:46920 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.91) (envelope-from ) id 1gAEgt-003GNv-Gw; Wed, 10 Oct 2018 08:38:19 -0500 Date: Wed, 10 Oct 2018 15:38:17 +0200 From: "Gustavo A. R. Silva" To: Tomas Winkler , Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] tpm: fix unused-value issues in tpm_try_transmit Message-ID: <20181010133817.GA11485@embeddedor.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) 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 - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 109.24.154.57 X-Source-L: No X-Exim-ID: 1gAEgt-003GNv-Gw X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 57.154.24.109.rev.sfr.net (embeddedor) [109.24.154.57]:46920 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 7 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, there are some values assigned to variable *rc*, which are never actually used in any computation, because such variable is updated at line 550, before they can be used: 549out: 550 rc = tpm_go_idle(chip, flags); 551 if (rc) 552 goto out; Fix this by removing such assignments. Addresses-Coverity-ID: 1470245 ("Unused value") Addresses-Coverity-ID: 1470250 ("Unused value") Addresses-Coverity-ID: 1470251 ("Unused value") Fixes: 627448e85c76 ("tpm: separate cmd_ready/go_idle from runtime_pm") Signed-off-by: Gustavo A. R. Silva --- drivers/char/tpm/tpm-interface.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index 129f640..8062736 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -512,7 +512,6 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, if (chip->ops->req_canceled(chip, status)) { dev_err(&chip->dev, "Operation Canceled\n"); - rc = -ECANCELED; goto out; } @@ -522,7 +521,6 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, chip->ops->cancel(chip); dev_err(&chip->dev, "Operation Timed out\n"); - rc = -ETIME; goto out; out_recv: @@ -533,14 +531,12 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, "tpm_transmit: tpm_recv: error %d\n", rc); goto out; } else if (len < TPM_HEADER_SIZE) { - rc = -EFAULT; goto out; } - if (len != be32_to_cpu(header->length)) { - rc = -EFAULT; + if (len != be32_to_cpu(header->length)) goto out; - } + rc = tpm2_commit_space(chip, space, ordinal, buf, &len); if (rc)