From patchwork Tue Jul 19 13:32:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 9237417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9AC1F602F0 for ; Tue, 19 Jul 2016 13:34:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BCE21FF27 for ; Tue, 19 Jul 2016 13:34:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 801992711E; Tue, 19 Jul 2016 13:34:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B3371FF27 for ; Tue, 19 Jul 2016 13:34:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753616AbcGSNeO (ORCPT ); Tue, 19 Jul 2016 09:34:14 -0400 Received: from mga01.intel.com ([192.55.52.88]:62141 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753290AbcGSNeN (ORCPT ); Tue, 19 Jul 2016 09:34:13 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 19 Jul 2016 06:33:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,389,1464678000"; d="scan'208";a="736626679" Received: from icremer-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.1.9]) by FMSMGA003.fm.intel.com with ESMTP; 19 Jul 2016 06:33:18 -0700 From: Jarkko Sakkinen To: Peter Huewe , Jason Gunthorpe Cc: linux-security-module@vger.kernel.org, Stefan Berger , Jarkko Sakkinen , Marcel Selhorst , tpmdd-devel@lists.sourceforge.net (moderated list:TPM DEVICE DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 3/5] tpm: return error code from tpm_gen_interrupt() Date: Tue, 19 Jul 2016 16:32:47 +0300 Message-Id: <1468935171-7815-4-git-send-email-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468935171-7815-1-git-send-email-jarkko.sakkinen@linux.intel.com> References: <1468935171-7815-1-git-send-email-jarkko.sakkinen@linux.intel.com> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Return error code from tpm_gen_interrupt() and fail tpm_tis family of drivers on a system error. It doesn't make sense to continue if we cannot even reach the TPM. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm-interface.c | 6 +++--- drivers/char/tpm/tpm.h | 2 +- drivers/char/tpm/tpm_tis_core.c | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index 88dafcd..35b2722 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap, * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing * a TPM error code. */ -void tpm_gen_interrupt(struct tpm_chip *chip) +int tpm_gen_interrupt(struct tpm_chip *chip) { const char *desc = "attempting to generate an interrupt"; u32 cap2; cap_t cap; if (chip->flags & TPM_CHIP_FLAG_TPM2) - tpm2_get_tpm_pt(chip, 0x100, &cap2, desc); + return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc); else - tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc); + return tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc); } EXPORT_SYMBOL_GPL(tpm_gen_interrupt); diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index ec1f877..0cbb598 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -483,7 +483,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, int len, const char *desc); int tpm_get_timeouts(struct tpm_chip *chip); -void tpm_gen_interrupt(struct tpm_chip *chip); +int tpm_gen_interrupt(struct tpm_chip *chip); int tpm1_auto_startup(struct tpm_chip *chip); int tpm_do_selftest(struct tpm_chip *chip); unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal); diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index b67d225..45159e1 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -575,7 +575,9 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, /* Generate an interrupt by having the core call through to * tpm_tis_send */ - tpm_gen_interrupt(chip); + rc = tpm_gen_interrupt(chip); + if (rc < 0) + return rc; /* tpm_tis_send will either confirm the interrupt is working or it * will call disable_irq which undoes all of the above.