Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6443935imu; Wed, 30 Jan 2019 15:02:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN7B21FMr6FXzonKFxvA9s04ieA786AwI3gzXtjnHu/X2f7WsRQVpt73Wz0jqnXinfuquJtS X-Received: by 2002:a17:902:f81:: with SMTP id 1mr31282621plz.174.1548889356112; Wed, 30 Jan 2019 15:02:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548889356; cv=none; d=google.com; s=arc-20160816; b=JyVPL79PUwPSnRRY9/4MDtOnt8JEfLeUNIugX/jCZCWzXwKMRnBqA+zyv8kKYfnlQi Ohag/yXVfGIiQgDKud4h025dfyuaeNlO0BhnctiVsl1+XsYbfc374XVhk3hWhzLabblx RJPK3/sL3/nPW4G+t/YQ4q34dfo9IHNLaNrNxg0WzMGV8JJ60WlKdAURqEAHawrzn1JW I93g4qkVv1xORjGNQyB679FwBWmCw9JnAGe8DbQGtV2yW2u+eJeztRGhD8fDmAvCicgT KHumtRz4EDg5iR+JvQQoG+qK7t5YYs/1w40e7DuoscmRHh9qw67c0f79sVsazKkSNUFk VIFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=7NFttO9FlRVaWp6/HGo/FohVzDnvruewd75jp/m9iLc=; b=SuekehxFmLJvDoFnR9RsK4nMYapj7YguHwmSihXJyCNC6Yc3wY7QNDbSyL2uuslnmA IVhYwGN3hDgtg8zhPJQpw2bG+s5BOEJrrovmppfj8aWLE/itIMULg40ZIswwA2S9h8Z0 0K4whPCqLEfacwFMiagV4TreI6vb421VXcch8hGYmrIRZM+7mHMJwIVTTSCx+ozN5mLK rvKDnIkT0b7Ka1YgYb9e8mMV4ICwJTPWdZrPEnv6UgThz3H3TAzP5aca3wUaaK/yVgQo EnM904j47D1pnhkw3Pes15RWA8iNQqBR0g3l4iYXnhMfonsonMyXWnORQ++c0sleGJcA +ChQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24si2771404plq.41.2019.01.30.15.02.20; Wed, 30 Jan 2019 15:02:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731352AbfA3XBs (ORCPT + 99 others); Wed, 30 Jan 2019 18:01:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37504 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbfA3XBm (ORCPT ); Wed, 30 Jan 2019 18:01:42 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE6AFC0495BB; Wed, 30 Jan 2019 22:43:45 +0000 (UTC) Received: from cantor.redhat.com (ovpn-116-165.phx2.redhat.com [10.3.116.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 658DA6266C; Wed, 30 Jan 2019 22:43:45 +0000 (UTC) From: Jerry Snitselaar To: linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Jarkko Sakkinen Subject: [PATCH 1/2] tpm: don't return bool from update_timeouts Date: Wed, 30 Jan 2019 15:43:32 -0700 Message-Id: <20190130224333.20373-1-jsnitsel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 30 Jan 2019 22:43:45 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set tpm_chip->timeouts_adjusted directly in the update_timeouts code instead of returning bool. In case of tpm read failing print warning that the read failed and continue on. Reviewed-by: Jarkko Sakkinen Signed-off-by: Jerry Snitselaar --- drivers/char/tpm/tpm1-cmd.c | 3 +-- drivers/char/tpm/tpm_tis_core.c | 15 +++++++++------ include/linux/tpm.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c index 6f306338953b..bda9a16b44f6 100644 --- a/drivers/char/tpm/tpm1-cmd.c +++ b/drivers/char/tpm/tpm1-cmd.c @@ -380,8 +380,7 @@ int tpm1_get_timeouts(struct tpm_chip *chip) * of misreporting. */ if (chip->ops->update_timeouts) - chip->timeout_adjusted = - chip->ops->update_timeouts(chip, timeout_eff); + chip->ops->update_timeouts(chip, timeout_eff); if (!chip->timeout_adjusted) { /* Restore default if chip reported 0 */ diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index bf7e49cfa643..45e29fd1f5d7 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -521,35 +521,38 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = { (TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } }, }; -static bool tpm_tis_update_timeouts(struct tpm_chip *chip, +static void tpm_tis_update_timeouts(struct tpm_chip *chip, unsigned long *timeout_cap) { struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); int i, rc; u32 did_vid; + chip->timeout_adjusted = false; + if (chip->ops->clk_enable != NULL) chip->ops->clk_enable(chip, true); rc = tpm_tis_read32(priv, TPM_DID_VID(0), &did_vid); - if (rc < 0) + if (rc < 0) { + dev_warn(&chip->dev, "%s: failed to read did_vid: %d\n", + __func__, rc); goto out; + } for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) { if (vendor_timeout_overrides[i].did_vid != did_vid) continue; memcpy(timeout_cap, vendor_timeout_overrides[i].timeout_us, sizeof(vendor_timeout_overrides[i].timeout_us)); - rc = true; + chip->timeout_adjusted = true; } - rc = false; - out: if (chip->ops->clk_enable != NULL) chip->ops->clk_enable(chip, false); - return rc; + return; } /* diff --git a/include/linux/tpm.h b/include/linux/tpm.h index b49a55cf775f..13563b8c0c3a 100644 --- a/include/linux/tpm.h +++ b/include/linux/tpm.h @@ -41,7 +41,7 @@ struct tpm_class_ops { int (*send) (struct tpm_chip *chip, u8 *buf, size_t len); void (*cancel) (struct tpm_chip *chip); u8 (*status) (struct tpm_chip *chip); - bool (*update_timeouts)(struct tpm_chip *chip, + void (*update_timeouts)(struct tpm_chip *chip, unsigned long *timeout_cap); int (*go_idle)(struct tpm_chip *chip); int (*cmd_ready)(struct tpm_chip *chip); -- 2.20.1.98.gecbdaf0899