Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5599909ima; Tue, 5 Feb 2019 14:48:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IaPflFminNGC5OySFWmzkfHZfpzAQpUsDHWVOuANwLIx3SMcdwh0WHPOmbqyZWmTuhUoNda X-Received: by 2002:a63:2d46:: with SMTP id t67mr6866105pgt.140.1549406923634; Tue, 05 Feb 2019 14:48:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549406923; cv=none; d=google.com; s=arc-20160816; b=FUdjBonPgiz/2G19QLfaCKXUqQHZJpnQbSEs070pPDksarqxF9VIogxiPosch9OwDE ctabvoGL3rnG5rNlslBghJCruto4pt8Skqg2zXegV8/kmufDLPYXqK4lxlE3eywI69wu 5A3ccVR3Tjhsy0NyzcWEtzpA4BOs3C6Ia/OgkkhjT08JbnHGRKMjykilb2Hx+Iu4nq6w y9kXxTa/rtusT8AP4URvvrt71dDuufSK38jIjEHGDv8RHh4mb/G4IEl6Yvh8Dak33B6l W4WeuJeemJB3jREYRcCrqYT1uxZ1EndPiNKeQ4l0vGTRcPMp6lN8yXF5OKon/YjHikjG Ta+Q== 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=ituSU23VHb25mht6CHv6aRVc+wT8gzATHEi3CCu3Ugc=; b=emoDNXQzXoQqVD9hSZs1m8MNrXzqWwqc9pU9mWdJft6in7CPhqJrWEQIC5UnvJkzoI dU0fJZFpOvcPth7Hqegc9hRfbsWdXAR/+f/jUrNcDMDTci1ZqQPjety/rcKIrf3IijDz Am1yqWLKOh4kfa+yNmIxBUTaeP4y3OX1Nmw2CWi0Nfrj+3Dn8wC4fm8gYCUgQEDf2LDp Zm2VygRjkuFxhzb/D+FvAvVSef5qnrO0Aiqh9IX9Ozhm0kKtzRQgJPMCfLiP4ohflXWH XAxPs2xjrBVLou4LuGdGse4C2piftAN9PncAFRC+Ns+J7Tkf3XyOGXUoWbB/2Vw5MOwW aSlA== 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 q17si1813630pgv.426.2019.02.05.14.48.27; Tue, 05 Feb 2019 14:48:43 -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 S1730748AbfBEWr6 (ORCPT + 99 others); Tue, 5 Feb 2019 17:47:58 -0500 Received: from mga06.intel.com ([134.134.136.31]:62899 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730368AbfBEWrz (ORCPT ); Tue, 5 Feb 2019 17:47:55 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2019 14:47:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,337,1544515200"; d="scan'208";a="113982120" Received: from ibanaga-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.254.171]) by orsmga006.jf.intel.com with ESMTP; 05 Feb 2019 14:47:49 -0800 From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Peter Huewe , Jason Gunthorpe , Tomas Winkler , Tadeusz Struk , Stefan Berger , Nayna Jain , Jarkko Sakkinen Subject: [PATCH v11 03/16] tpm: return 0 from pcrs_show() when tpm1_pcr_read() fails Date: Wed, 6 Feb 2019 00:47:10 +0200 Message-Id: <20190205224723.19671-4-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190205224723.19671-1-jarkko.sakkinen@linux.intel.com> References: <20190205224723.19671-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 Reviewed-by: Stefan Berger Tested-by: Stefan Berger Reviewed-by: Jerry Snitselaar Reviewed-by: James Bottomley --- 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