From: Jarkko Sakkinen Subject: [PATCH v2 3/6] tpm: return error code from tpm_gen_interrupt() Date: Sun, 26 Jun 2016 00:44:48 +0300 Message-ID: <1466891093-27766-4-git-send-email-jarkko.sakkinen@linux.intel.com> References: <1466891093-27766-1-git-send-email-jarkko.sakkinen@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1466891093-27766-1-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Peter Huewe , Jason Gunthorpe Cc: open list , linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "moderated list:TPM DEVICE DRIVER" List-Id: tpmdd-devel@lists.sourceforge.net 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 e953618..4aeacf3 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 0f16d18..8153f93 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 tpm_do_selftest(struct tpm_chip *chip); unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal); int tpm_pm_suspend(struct device *dev); diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index c7dc58d..79168ca 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -580,7 +580,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. -- 2.7.4 ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape