Message ID | a820eaf8c77ca4fde50fc170f535de4b28c82a2d.1677322706.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1431643wrd; Sat, 25 Feb 2023 03:06:50 -0800 (PST) X-Google-Smtp-Source: AK7set/XQs1TNqhYuMToKiebDA6Sr/bOmvH3mHN2fbfavNhAgcBFRx93Rcl9uBgy4JU5sviQCIYN X-Received: by 2002:a17:907:d13:b0:8ec:439f:18fb with SMTP id gn19-20020a1709070d1300b008ec439f18fbmr3124993ejc.29.1677323210472; Sat, 25 Feb 2023 03:06:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677323210; cv=none; d=google.com; s=arc-20160816; b=AQd8NFoS+zgLr5sZKlhb6HlHqb1Mt8tViwP9we1aPd+CV2Pj1/QRfosf3SKVyssJ8a m2hSptPOB2J0MYoEqKFwVrmcSRdvGUvAB/X7tz2fbhL6ldVh/FT+LdqrDjZw5M1bYTZY iM6JwliUCGdOB3nD51s1smQeSqeKdlLgtf7qTCswMP2IuoQLszFK8i9nqpxlPUwT6RPr JXDzMAElTiCvgTlkAedErkb9JOFc+tlwy3yAbpcWYua1qm//rLsPn9AGQpExHteDuXtx 3nWApbqo5guy6ZjNkAsz+L72hyA/oM5IX7/xYPfjvH6y7N5Dab2VdqXpuEJcS6X2/dDt bheg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=CzReFEkkHKldaALgjpoQfdEl+EPEdC73IWihqtKbvl0=; b=PCEX+99ymrqzQ7qnP2TAtUpNebV2+yNx5zEg/DWmxmfLMRQyhEwnKc66i/x3JvvEw4 kVERwQVUUwfynmAr7lHNluksBKmHtHk0lbcgRqYFTrnjy3jlEYoA5cK+rMN4fbZbX+Re KohlHZqWQr+172GbjD75oZvUzozUw9i/H8hzlTCPDgf586T61HG7HCbjjCbkLcCc2F6g VvhvZtbnX7BfW70TiC+ieYoxprAShbAXxLpNQdFxpcmAFmoKdqYOSMX47mrQdfD9e9WR A5jWexOY2XfpwNOdPDnm0a653RR7bboIQAQJyxAxYQTQ+rS7pxIgoeMjw3sBRczl8LGM A4Uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r8-20020a170906c28800b008c2690d9f7esi1687839ejz.918.2023.02.25.03.06.26; Sat, 25 Feb 2023 03:06:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229582AbjBYK64 (ORCPT <rfc822;guoshuai5156@gmail.com> + 99 others); Sat, 25 Feb 2023 05:58:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjBYK6z (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 25 Feb 2023 05:58:55 -0500 Received: from smtp.smtpout.orange.fr (smtp-12.smtpout.orange.fr [80.12.242.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8039112BC5 for <linux-kernel@vger.kernel.org>; Sat, 25 Feb 2023 02:58:53 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id VsGQpbpJVHeiPVsGRphwXq; Sat, 25 Feb 2023 11:58:51 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 25 Feb 2023 11:58:51 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Peter Huewe <peterhuewe@gmx.de>, Jarkko Sakkinen <jarkko@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>, Matthew Garrett <mjg59@srcf.ucam.org> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-integrity@vger.kernel.org Subject: [PATCH] tpm_crb: Fix an error handling path in crb_acpi_add() Date: Sat, 25 Feb 2023 11:58:48 +0100 Message-Id: <a820eaf8c77ca4fde50fc170f535de4b28c82a2d.1677322706.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758800862640231592?= X-GMAIL-MSGID: =?utf-8?q?1758800862640231592?= |
Series |
tpm_crb: Fix an error handling path in crb_acpi_add()
|
|
Commit Message
Christophe JAILLET
Feb. 25, 2023, 10:58 a.m. UTC
Some error paths don't call acpi_put_table() before returning.
Branch to the correct place instead of doing some direct return.
Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/char/tpm/tpm_crb.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
On Sun, Aug 20, 2023 at 08:21:47AM +0200, Christophe JAILLET wrote: > Le 25/02/2023 à 11:58, Christophe JAILLET a écrit : > > Some error paths don't call acpi_put_table() before returning. > > Branch to the correct place instead of doing some direct return. > > > > Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton") > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > --- > > drivers/char/tpm/tpm_crb.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c > > index 99698ee1a744..f7068bd8b3d0 100644 > > --- a/drivers/char/tpm/tpm_crb.c > > +++ b/drivers/char/tpm/tpm_crb.c > > @@ -771,12 +771,13 @@ static int crb_acpi_add(struct acpi_device *device) > > FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", > > buf->header.length, > > ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON); > > - return -EINVAL; > > + rc = -EINVAL; > > + goto out; > > } > > crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf)); > > rc = crb_map_pluton(dev, priv, buf, crb_pluton); > > if (rc) > > - return rc; > > + goto out; > > } > > priv->sm = sm; > > Hi, > > polite reminder. > > While re-looking at it, the 3rd parameter of crb_map_pluton() (i.e. buf) > looks unused and could be removed if it makes sense to you. For the original patch: ACKed-by: Matthew Garrett <mgarrett@aurora.tech> I'm actually re-working the pluton mapping code because right now it's impossible to use localities because the ACPI table is unhelpful and I think that can be worked around.
On Sun Aug 20, 2023 at 9:21 AM EEST, Christophe JAILLET wrote: > Le 25/02/2023 à 11:58, Christophe JAILLET a écrit : > > Some error paths don't call acpi_put_table() before returning. > > Branch to the correct place instead of doing some direct return. > > > > Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton") > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > --- > > drivers/char/tpm/tpm_crb.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c > > index 99698ee1a744..f7068bd8b3d0 100644 > > --- a/drivers/char/tpm/tpm_crb.c > > +++ b/drivers/char/tpm/tpm_crb.c > > @@ -771,12 +771,13 @@ static int crb_acpi_add(struct acpi_device *device) > > FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", > > buf->header.length, > > ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON); > > - return -EINVAL; > > + rc = -EINVAL; > > + goto out; > > } > > crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf)); > > rc = crb_map_pluton(dev, priv, buf, crb_pluton); > > if (rc) > > - return rc; > > + goto out; > > } > > > > priv->sm = sm; > > Hi, > > polite reminder. > > While re-looking at it, the 3rd parameter of crb_map_pluton() (i.e. buf) > looks unused and could be removed if it makes sense to you. This AFAIK went to Linux v6.2 already. BR, Jarkko
rn Tue Aug 22, 2023 at 2:28 PM EEST, Jarkko Sakkinen wrote: > On Sun Aug 20, 2023 at 9:21 AM EEST, Christophe JAILLET wrote: > > Le 25/02/2023 à 11:58, Christophe JAILLET a écrit : > > > Some error paths don't call acpi_put_table() before returning. > > > Branch to the correct place instead of doing some direct return. > > > > > > Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton") > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > > --- > > > drivers/char/tpm/tpm_crb.c | 5 +++-- > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c > > > index 99698ee1a744..f7068bd8b3d0 100644 > > > --- a/drivers/char/tpm/tpm_crb.c > > > +++ b/drivers/char/tpm/tpm_crb.c > > > @@ -771,12 +771,13 @@ static int crb_acpi_add(struct acpi_device *device) > > > FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", > > > buf->header.length, > > > ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON); > > > - return -EINVAL; > > > + rc = -EINVAL; > > > + goto out; > > > } > > > crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf)); > > > rc = crb_map_pluton(dev, priv, buf, crb_pluton); > > > if (rc) > > > - return rc; > > > + goto out; > > > } > > > > > > priv->sm = sm; > > > > Hi, > > > > polite reminder. > > > > While re-looking at it, the 3rd parameter of crb_map_pluton() (i.e. buf) > > looks unused and could be removed if it makes sense to you. > > This AFAIK went to Linux v6.2 already. Sorry I overlooked! There was bunch of patches with almost similar name, so I must have overlooked also back then. Now it is applied. Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> BR, Jarkko
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index 99698ee1a744..f7068bd8b3d0 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c @@ -771,12 +771,13 @@ static int crb_acpi_add(struct acpi_device *device) FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", buf->header.length, ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON); - return -EINVAL; + rc = -EINVAL; + goto out; } crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf)); rc = crb_map_pluton(dev, priv, buf, crb_pluton); if (rc) - return rc; + goto out; } priv->sm = sm;