Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp143615imu; Thu, 8 Nov 2018 06:18:32 -0800 (PST) X-Google-Smtp-Source: AJdET5cnnEP8Ys21MiDRq+Js8BcixXqX6EeyA1EJhRVlIR8/qjb99hg0xIJcjkG5aV3gGxcymwXy X-Received: by 2002:a62:9f42:: with SMTP id g63-v6mr4639563pfe.144.1541686712803; Thu, 08 Nov 2018 06:18:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541686712; cv=none; d=google.com; s=arc-20160816; b=x2ckEq1XVpc7QmRdH7C/TkG++NrlasswPxCRq3NnU3rwf9zX9mCCoztkCjqKAH4hMV xMOdponRZf7+v6eNCwpaZuCSo4KTRBFWCmryVrjyRJcmFrZvRkSZ1WueGQpinqFh9v2p 4XK54oLsUsfIM0bvGiRpJXQJ8m7miRQYwzlepmZ/txM1qkKl+cZwWtmLiIkfMI0G/YDJ cMXbfuUiCxm58NyKU9XLLvbXLXusgn03m8nTc5x4C71cZ9FOQZnJSlpBF9ArJMPYmH4m fVc5NtCyhcaOdZfgBXhVeVLZKwdVGiNCvFzlx650MuAKQZO3EhfjWGSiJRkNVtiZkX4G xt3Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VNs4SD/AAeP6rf4W68ooB4d59YDAB3ZOLvdxZGagMa8=; b=TeeD7oayY6iR3PU4UwtvghC7j6CpqLl096dobSYINsjkd46hw0hwx7ke2f8V6k3VQe mKArLvKSAoRo39Sui2h7AmMs05ws4l2I74qvEueMdKpRCN4qh+lFseoXjXtPCvIRobE2 YI176vucBLTaYC7eFjybeCpz5fLfXYLJlox1ZFCF5ttBmiOqzSCRvp3hm6ymrSAuKHpo 5932VhxagwikFLp7yNokSPFAbmsza9AVx9ZajBQ3FBgJCLeKWWGJjFyOPguxNBWfvmVw nnjYI/Ha3TmVFclHL4lHqU0YO0z5+40Id/4I29V52AqEV1hTaLQ6Y6/W7ASKsJ/iVkAl QJ0g== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3-v6si4617318pfl.209.2018.11.08.06.18.17; Thu, 08 Nov 2018 06:18:32 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727378AbeKHXv4 (ORCPT + 99 others); Thu, 8 Nov 2018 18:51:56 -0500 Received: from mga18.intel.com ([134.134.136.126]:56438 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbeKHXv4 (ORCPT ); Thu, 8 Nov 2018 18:51:56 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Nov 2018 06:16:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,478,1534834800"; d="scan'208";a="94663787" Received: from ibanaga-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.254.75]) by FMSMGA003.fm.intel.com with ESMTP; 08 Nov 2018 06:16:09 -0800 From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Cc: linux-security-module@vger.kernel.org, James Bottomley , Tomas Winkler , Tadeusz Struk , Stefan Berger , Nayna Jain , Jarkko Sakkinen , Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 03/17] tpm: return 0 from pcrs_show() when tpm1_pcr_read() fails Date: Thu, 8 Nov 2018 16:15:24 +0200 Message-Id: <20181108141541.12832-4-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108141541.12832-1-jarkko.sakkinen@linux.intel.com> References: <20181108141541.12832-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not print partial list of PCRs when tpm1_pcr_read() fails but instead return 0 from pcrs_show(). This is consistent behavior with other sysfs functions. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm-sysfs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c index 7ed7eb6f906a..928d4e839bb7 100644 --- a/drivers/char/tpm/tpm-sysfs.c +++ b/drivers/char/tpm/tpm-sysfs.c @@ -100,22 +100,21 @@ static ssize_t pcrs_show(struct device *dev, struct device_attribute *attr, { cap_t cap; u8 digest[TPM_DIGEST_SIZE]; - ssize_t rc; u32 i, j, num_pcrs; char *str = buf; struct tpm_chip *chip = to_tpm_chip(dev); - rc = tpm1_getcap(chip, TPM_CAP_PROP_PCR, &cap, - "attempting to determine the number of PCRS", - sizeof(cap.num_pcrs)); - if (rc) + if (tpm1_getcap(chip, TPM_CAP_PROP_PCR, &cap, + "attempting to determine the number of PCRS", + sizeof(cap.num_pcrs))) return 0; num_pcrs = be32_to_cpu(cap.num_pcrs); for (i = 0; i < num_pcrs; i++) { - rc = tpm1_pcr_read(chip, i, digest); - if (rc) + if (tpm1_pcr_read(chip, i, digest)) { + str = buf; break; + } str += sprintf(str, "PCR-%02d: ", i); for (j = 0; j < TPM_DIGEST_SIZE; j++) str += sprintf(str, "%02X ", digest[j]); -- 2.19.1