Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1575881imu; Sun, 18 Nov 2018 04:49:39 -0800 (PST) X-Google-Smtp-Source: AJdET5cwRkKN20FJzRyVj4brCbzZkqP0JI3rro75XlxPwOz7jKqeurrzj9TAinhPz+sKW6p2f/hY X-Received: by 2002:a62:3888:: with SMTP id f130mr6617229pfa.132.1542545379396; Sun, 18 Nov 2018 04:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542545379; cv=none; d=google.com; s=arc-20160816; b=fsXgYGCK4Kg4syUj0hMAA4nSrJMTKCdxxWzw45WAII4EK2pVEH8i4a1lAYPkawmBmX kfOhFCUoIw/7zGnTBEVQ0fbwSNmufJiHBX09ExhDD1ppwCYb50Xd6LFVP2nuC9LLXc3c RtRxjXMfKwcCp9WLx2ztnw0uK4pJWagKFpTTsQ4IiujSiIIHkxTJbzw20pY9dzrLIqXE f3m8mcVFXrpAxZmn0xu3t2H0KFEyK4jkKNg/a4+rS+tzbjDbgRzGFXoihXzNzduS1Qj8 GPAd86sQdqeIY5ygWkcZF4OZAp6ikELyfX64kwqAtvzxSeO0YOcPJmwNwrWGgVcRYUWN 6lTg== 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=vG/m3E0IXsTZK2PgZf/w4gY8rYKVnYjx1sYLe81CdlAe52gWcT85pX8S5XI6af6m2h JtLi4XwzjoJznyfvnww6nUGPEo4r08fYjK8kw4KPJqFqHQSpgle2RXUwjmfSnMcKsYU3 ndz962nm/yxNoU+yK2pptyzI4w+zn8OI66ttznzCi3889NuNQ2CATWpHQjNlA73XVU8W G41unWLrhrSR3PPavXcxvn0IDu6PrO0pcCRWnxDCCT9avV+rB3fyuHcfirFTL/LPhWEX KdnMADTxchbXkU20tRsYI4tK/+RYrwEJltMP4CJbf3F9eqO5MaIBCiCP5jxhBCuiyh+K +5ww== 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 k64si35445565pge.7.2018.11.18.04.49.24; Sun, 18 Nov 2018 04:49:39 -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 S1727388AbeKRXIm (ORCPT + 99 others); Sun, 18 Nov 2018 18:08:42 -0500 Received: from mga17.intel.com ([192.55.52.151]:7127 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726180AbeKRXIm (ORCPT ); Sun, 18 Nov 2018 18:08:42 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Nov 2018 04:48:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,248,1539673200"; d="scan'208";a="107258481" Received: from tmuluk-mobl4.ger.corp.intel.com (HELO localhost) ([10.249.254.142]) by fmsmga004.fm.intel.com with ESMTP; 18 Nov 2018 04:48:21 -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 v9 03/17] tpm: return 0 from pcrs_show() when tpm1_pcr_read() fails Date: Sun, 18 Nov 2018 14:47:36 +0200 Message-Id: <20181118124753.18613-4-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181118124753.18613-1-jarkko.sakkinen@linux.intel.com> References: <20181118124753.18613-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