From patchwork Sat Feb 25 10:58:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 61508 Return-Path: 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 + 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 ); 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 ; 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 To: Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Matthew Garrett Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , 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: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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: 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?= 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 ACKed-by: Matthew Garrett Reviewed-by: Jarkko Sakkinen --- 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;