From patchwork Wed Jun 29 23:26:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12900794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D339BC43334 for ; Wed, 29 Jun 2022 23:27:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231361AbiF2X1k (ORCPT ); Wed, 29 Jun 2022 19:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbiF2X1i (ORCPT ); Wed, 29 Jun 2022 19:27:38 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F27525280; Wed, 29 Jun 2022 16:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656545244; bh=8bvwjFzHTyN26RyydHQkqmMi4yXOCOXQzUZ4H55Cz3k=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=FrsMyOxlLPHj0Tow/axOBTr3wlJNmmROtrdlpcVVoUeQmcl/RGCOQkXVXSW35BWSI Ki0mRaewvoU/C8AYf4R6lmeY4TXro7fukJGoMTyrvC4Sq4hpQYMujgVkeisFyRzqET gHhT3PGBVaX7Nk2J1khj33UnKwj1eKqXasCtqA1c= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([46.223.3.23]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mlf0K-1nP8oQ1bs2-00ikC5; Thu, 30 Jun 2022 01:27:24 +0200 From: Lino Sanfilippo To: peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca Cc: stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH v7 03/10] tpm, tpm_tis: Disable interrupts if tpm_tis_probe_irq() failed Date: Thu, 30 Jun 2022 01:26:46 +0200 Message-Id: <20220629232653.1306735-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629232653.1306735-1-LinoSanfilippo@gmx.de> References: <20220629232653.1306735-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZEm7Xr3wPZL8SwaVhzJKfajnZv1T/Wh0WBV/B78vB3xkgDwvz9V OMdOhATHxNjcxay4ENz7BvqLOhPr01uXgKAWKChBQjY/Beqt84zAQP7opn2qHGDvpAxNDUw Lv3YR4+k6iMS4NNXdCziEVGYSK5J/4GbSEtme5A3DmDO82PmQiYDPJRZmJWRXm9Dhz7Hfyr ZLVwbvAlgog34Z33wkxDw== X-UI-Out-Filterresults: notjunk:1;V03:K0:WzdQ9i/npDM=:3pl8kCLN1WwvFMKdq5JqUm pkga61uB3/gyge304Fy7pqsZGRkkxk5FkYDYDp35jME8pLAWTY6YjwZj6wv/z2FBEmMKYSITn M5Ip6LI0yOgIW72QtEWEPKDssTEBfrtO8iXMkqxSC/8p4iNKM+RXDwjfKIKy5N5LnxvguCEse CMU1gRu0LU7wq4a+Yex1A05tKIL7dPJK8B/SHaET7rVtD0g0IPI4iCpm9VoUzL7aY8UaQLk9N xL2hxwhtz3mb9kB7SzM9afJnmjNSLKLo7aiJ1QHWZid3h3NYGLA3xSRA6kuzyrxms1IOVRQb2 5Wzbtx4i92FXWvINMQBJzz1GTvk3ye/0fBhG3oZFuYt8NvT+64rb9mkAxG0W7u4spzG2imOp+ wH4SRD2smbU3z61E0z3t4dUB5crLd88mGypn5FspxRZApky1zPK/CMyxBAGwBruDhV10dnaTG 7u2WYeGiOyD+JTGiQzTD9wdsxe/ggAMnuU78BqpBlzLs1u7QEZi0FKVU2nKv8w7ym2axyFpVL JgiVSvC3vExMGD7vfJlka00T55xzSLMhLRLKDbB8kYLhUDF/W2fEbGErk8rbKUAI+Ifekywyw TUzZJkzq9mxP767JjUQxI+XSY+INR+5ZEs6CSFf6d47JA/Bmp33XNiei9Zj41/rNnskt9/S8J H38F1WYlX0eYjO4yowxSBltWSlwR62xcPZs042OUncHNeBUcG2M5cOtuszTMLgTVXFywWdqRU db9QEiVLDnr8TK/ZTIKHJfCXtZnQ7+54mU7MtJt5BQAehSNiVkJ43RFXoEhwGOcapA1+Aix6d ngQKFpEgoZtdWnWBym0Vyg/4DhWqEjLZlcOuwNy4nOCZmpIL8+SqWE7WIq9dpUp7J8cz/Ebx4 HsRMP4YLwjIlj6gkGzRMqToCMWCoZcSV5xnQE8pdDws8JyxcHK5JVwo+grvVIjfH0JeZuYxZ+ xttIZgSWptGxU+zlhaf7M3bfCjhN1gVvKgflvvyzDx/MBT5WTDZEHmxod51GGjrnnBEx9Jfdm Wx8nQT+dyAF2M2DTkRvqCfOvKJEx05mrZHfkTo8WIvM/NLYGPgWtrBLDRhKs3l68r6np6rGmz 1K6bXx4ZdPtiHy2IVSIgKkJ+IIrAOTm/wWm9oc/YlnXliDJQjWWjDl/Rw== Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org From: Lino Sanfilippo Both functions tpm_tis_probe_irq_single() and tpm_tis_probe_irq() may setup the interrupts and then return with an error. This case is indicated by a missing TPM_CHIP_FLAG_IRQ flag in chip->flags. Currently the interrupt setup is only undone if tpm_tis_probe_irq_single() fails. Undo the setup also if tpm_tis_probe_irq() fails. Signed-off-by: Lino Sanfilippo Reviewed-by: Jarkko Sakkinen Tested-by: Michael Niewöhner --- drivers/char/tpm/tpm_tis_core.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 0e68e4502a56..d32e93c86f48 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1077,21 +1077,21 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, goto out_err; } - if (irq) { + if (irq) tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, irq); - if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) { - dev_err(&chip->dev, FW_BUG + else + tpm_tis_probe_irq(chip, intmask); + + if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) { + dev_err(&chip->dev, FW_BUG "TPM interrupt not working, polling instead\n"); - rc = request_locality(chip, 0); - if (rc < 0) - goto out_err; - disable_interrupts(chip); - release_locality(chip, 0); - } - } else { - tpm_tis_probe_irq(chip, intmask); + rc = request_locality(chip, 0); + if (rc < 0) + goto out_err; + disable_interrupts(chip); + release_locality(chip, 0); } }