Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5295532imu; Tue, 13 Nov 2018 04:28:08 -0800 (PST) X-Google-Smtp-Source: AJdET5d6FCFlwaFjTfzQzVi50DTQP17epJ300eEQwpWP7a0xQX1XNSTV7EnLjWWU28H5NBna0KvP X-Received: by 2002:a17:902:443:: with SMTP id 61-v6mr4815575ple.216.1542112088809; Tue, 13 Nov 2018 04:28:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542112088; cv=none; d=google.com; s=arc-20160816; b=fLWhG2vpGhbgGFGtPvfenzXOy3pbcCVJr5yE/+KNcPxXrem1SDxyXxI2qx9Gpmvnbd 1hEwqNF4yfQ93nepR9cVX3Y7V2mpogL0cCjyXdBupaQQaYYdvdGxOp6wjmBnaZnlsdFJ 6veSYE0Uqg5qZ7lEwGWrcTJX2lcQJ6NPFDZIjNruAtT5gldXqa5Tpv0DPw4y04Fm+FdH VLkFPd4abN6N6aMqBXZuCNUGfrE3GTf+HHe7xGvALLlW9TvoTYRM/gTkvOx7ueMtenFV rb10jnHSqPJXxAyXltMRCGLLVyMt/blnqJEvFlXZ9nWFy1b1RcRZU9NAl/5Vl6x672EA S+WQ== 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=ecLq859RwqIEiKgpABrRQnmjGF1CZ05iRmxMvgGYlzI=; b=i8Mm/ujl3w+Sx2sKWrnb6xKAvX4qdrUGaZDdqsayM0j+N+s4aaT/IgJBg07FNTWbQV GW2LnBbDs2Dk4MRYfYdhyDyUfN7b+nn/fTk7GokyOPN1LBt9pEQ+PvmR8V6aAvWMKjWU FNtn5gEYWk2QgaGK8Ad2622TitjpQqFaxytwBJgCqlxAPIvvWxVpEFfFGRlFEQOU+Jj7 keYosaZTiNl1sadWNfLuxZPGFfutUEWixS68keE/2OwpcUsDSkmhRu8Em2wrzbTfIVdk js9fn8oJFEHhIDxxe8+gce7BW11pb1Ugvr+fTVIspIZVciw8xpvZCv/TLEeSP+7Uz7ny 83SA== 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 w12-v6si15245391pld.221.2018.11.13.04.27.50; Tue, 13 Nov 2018 04:28:08 -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 S1733090AbeKMWY6 (ORCPT + 99 others); Tue, 13 Nov 2018 17:24:58 -0500 Received: from mga02.intel.com ([134.134.136.20]:57746 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732592AbeKMWY5 (ORCPT ); Tue, 13 Nov 2018 17:24:57 -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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2018 04:27:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,499,1534834800"; d="scan'208";a="108176504" 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:57 -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 05/17] tpm: print tpm2_commit_space() error inside tpm2_commit_space() Date: Tue, 13 Nov 2018 14:25:54 +0200 Message-Id: <20181113122609.21643-6-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 The error logging for tpm2_commit_space() is in a wrong place. This commit moves it inside that function. Cc: James Bottomley Signed-off-by: Jarkko Sakkinen Reviewed-by: Stefan Berger --- drivers/char/tpm/tpm-interface.c | 8 ++------ drivers/char/tpm/tpm2-space.c | 9 ++++++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index c9efd1b9fd2c..7ffb16edab6f 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -268,14 +268,10 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, rc = -EFAULT; out_space: - if (rc) { + if (rc) tpm2_flush_space(chip); - } else { + else rc = tpm2_commit_space(chip, space, ordinal, buf, &len); - if (rc) - dev_err(&chip->dev, "tpm2_commit_space: error %d\n", - rc); - } out_idle: /* may fail but do not override previous error value in rc */ diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c index d53c882268ff..3d5f9577e5de 100644 --- a/drivers/char/tpm/tpm2-space.c +++ b/drivers/char/tpm/tpm2-space.c @@ -501,19 +501,19 @@ int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, rc = tpm2_map_response_header(chip, cc, buf, *bufsiz); if (rc) { tpm2_flush_space(chip); - return rc; + goto out; } rc = tpm2_map_response_body(chip, cc, buf, *bufsiz); if (rc) { tpm2_flush_space(chip); - return rc; + goto out; } rc = tpm2_save_space(chip); if (rc) { tpm2_flush_space(chip); - return rc; + goto out; } *bufsiz = be32_to_cpu(header->length); @@ -526,4 +526,7 @@ int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, memcpy(space->session_buf, chip->work_space.session_buf, PAGE_SIZE); return 0; +out: + dev_err(&chip->dev, "%s: error %d\n", __func__, rc); + return rc; } -- 2.19.1