Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5295200imu; Tue, 13 Nov 2018 04:27:47 -0800 (PST) X-Google-Smtp-Source: AJdET5ett4vkSXkLPt77SCDi7m3tE7PAQOu3DNIEaKeCOoEZJtCBAMj2cthPROb1+2qdxmS7ogyQ X-Received: by 2002:a62:7796:: with SMTP id s144-v6mr5036368pfc.159.1542112067562; Tue, 13 Nov 2018 04:27:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542112067; cv=none; d=google.com; s=arc-20160816; b=f4cCOD7xGLEi0gIxFz0s11ctuxwHwnhBgxV+3iQQ+PW9ozgPfdFufYEeR5yQqweu2o z9jdAefmTHLFe6uQzFJTihNrzoqxYttAgMXnMgwhnrF1Op5e4XG5HC4TVrVvQXwCwI+0 b9sQHuNDAtH7Tu4xsIx70bNDMhICz3S2W8GA+uIMcJj3GMKsQ1Tgfv++u7yAWl5D+lRQ wHA02bjqIei7cwORAtfR/S+rC1q0PB9beakmGqnUpMjwijXpr1boW3ZnKHVwOhtq2mOA 1MWYgzl/u6Pmv9vevMIadDQyatAG8oKL4YKVfjBSdmUc073obIiPtTYmA9FAyrBq8Isf bD4A== 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=0PI/HBmOQnLh3iUMYcU/1F1DcNkF8sVysXNbse9VBPA=; b=NACcRszjav2h/gZEbwhZbtjWyqzaudkaYLoxGVXqz+SZn9a6KDl5lYP/CukxXv1mp2 BDVGhVLWCcS+vWuPC4z55B/K0azcE8ZBIVLAJiav3SYz6JXlGOvfm+8HlBVBHxOh34lJ yTIjSyyz/LOpiFv2LPXOZOof6l38vlexsPLrQRDaTV3OHlrkBygaSi+MOuL87BE4/gVn YJf1EoyHTG2sCFeUnjkEYXoRXfMgtYKcqdJ2nsfI7W0l5Lhgw+EaB/COdU9QQZODc/yN K09/4BRFp1/s+5YLbmAUzqPMBR+duhl9t0H2TTLxdLa2831WWaQZnmcQ467qLy2DQoVu TVXA== 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 e188-v6si17775155pfe.203.2018.11.13.04.27.30; Tue, 13 Nov 2018 04:27:47 -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 S1733044AbeKMWYk (ORCPT + 99 others); Tue, 13 Nov 2018 17:24:40 -0500 Received: from mga14.intel.com ([192.55.52.115]:48544 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732592AbeKMWYk (ORCPT ); Tue, 13 Nov 2018 17:24:40 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2018 04:26:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,499,1534834800"; d="scan'208";a="108176444" Received: from ibanaga-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.254.77]) by orsmga002.jf.intel.com with ESMTP; 13 Nov 2018 04:26:39 -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 v6 03/17] tpm: return 0 from pcrs_show() when tpm1_pcr_read() fails Date: Tue, 13 Nov 2018 14:25:52 +0200 Message-Id: <20181113122609.21643-4-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181113122609.21643-1-jarkko.sakkinen@linux.intel.com> References: <20181113122609.21643-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 --- 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