From patchwork Thu Nov 17 11:23:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 21590 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp351360wrr; Thu, 17 Nov 2022 03:42:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Y1IBuJ3q25knjsGFAgIH1haAyTXJls75RXZqVE2PuggBepZr729kd4w0jXJaEQBDbVI11 X-Received: by 2002:a17:906:4dc3:b0:79d:f5f2:621e with SMTP id f3-20020a1709064dc300b0079df5f2621emr1735635ejw.362.1668685323494; Thu, 17 Nov 2022 03:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668685323; cv=none; d=google.com; s=arc-20160816; b=e3wTuYS2h28YANIhtQiaxqRXoC+cpuIBQ1w64IYXphQebvIvMXfdz1n+Y4Qk7uLZqC m+knsWQEIXYIuhNLRONNRMuEf46ro305p1Q/iXLmY6OypmCpgscu88OhpcbPuczQXBy8 u4Ue8E2l5qiiM1oA8ZKAu801thmqf45LHFihlJOGnmcESFmQNoT1RYEqYSSuMMliyztV DmzWGM73DenBF1HP8qZk3q1umLw/HLHlLXNpK85QPUid46XxcQQVhwZH0cNPfIVrZ9qQ cC+2hltjEYRnjc663UI4ZUajDBM2kwHE1FoMnayaMcI5U0diDqWV+le91WJ8T4eDqZH9 94xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=EJj/iw5luuyl/MQRPihcP9Z3tmuPsmtCm6tVvCR7LVM=; b=0dqYG7JJ8AvNyN42nQajHfppHsD0DeuJfUcGTzsDKFstJXcKsG90BBU4orSDCtAZ8X TX+7T2B+7ZRrdibhWIxrF6KktBvLrrfAP83d5zjZbfOBDg+9r/SAHa8wWFT3VBryMlTs GUqhkte+oE1rlExwUUfbz52NAUf/+SP4W89blAk9jHgblkKRCgYEer03zdrdd3HAB3hi Y1gFFlV5lKHJRp23MIo+tCalohMc1+K7NE3eCbx6frzCHBaCLnbwmgA0ndcEdxdAVv9a XILOcVR/NPtGastKEiGxX+XZt4l634Iwbgdbl2UAJJNNHlp67Nc2KbTFRWJGYU00kH1K llWw== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd40-20020a1709076e2800b0077a19529760si458524ejc.65.2022.11.17.03.41.39; Thu, 17 Nov 2022 03:42:03 -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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239873AbiKQLjr (ORCPT + 99 others); Thu, 17 Nov 2022 06:39:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239853AbiKQLjK (ORCPT ); Thu, 17 Nov 2022 06:39:10 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 444A86828E; Thu, 17 Nov 2022 03:39:06 -0800 (PST) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NCdGK5MZjzHvsd; Thu, 17 Nov 2022 19:38:33 +0800 (CST) Received: from dggpemm500002.china.huawei.com (7.185.36.229) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 17 Nov 2022 19:39:05 +0800 Received: from linux-ibm.site (10.175.102.37) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 17 Nov 2022 19:39:04 +0800 From: Hanjun Guo To: Jarkko Sakkinen , Peter Huewe CC: , , "Hanjun Guo" Subject: [PATCH v2 3/3] tpm: tpm_tis: Add the missed acpi_put_table() to fix memory leak Date: Thu, 17 Nov 2022 19:23:42 +0800 Message-ID: <1668684222-38457-4-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1668684222-38457-1-git-send-email-guohanjun@huawei.com> References: <1668684222-38457-1-git-send-email-guohanjun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1749743382029655746?= X-GMAIL-MSGID: =?utf-8?q?1749743382029655746?= In check_acpi_tpm2(), we get the TPM2 table just to make sure the table is there, not used after the init, so the acpi_put_table() should be added to release the ACPI memory. Fixes: 4cb586a188d4 ("tpm_tis: Consolidate the platform and acpi probe flow") Cc: stable@vger.kernel.org Signed-off-by: Hanjun Guo Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index bcff642..ed5dabd 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -125,6 +125,7 @@ static int check_acpi_tpm2(struct device *dev) const struct acpi_device_id *aid = acpi_match_device(tpm_acpi_tbl, dev); struct acpi_table_tpm2 *tbl; acpi_status st; + int ret = 0; if (!aid || aid->driver_data != DEVICE_IS_TPM2) return 0; @@ -132,8 +133,7 @@ static int check_acpi_tpm2(struct device *dev) /* If the ACPI TPM2 signature is matched then a global ACPI_SIG_TPM2 * table is mandatory */ - st = - acpi_get_table(ACPI_SIG_TPM2, 1, (struct acpi_table_header **)&tbl); + st = acpi_get_table(ACPI_SIG_TPM2, 1, (struct acpi_table_header **)&tbl); if (ACPI_FAILURE(st) || tbl->header.length < sizeof(*tbl)) { dev_err(dev, FW_BUG "failed to get TPM2 ACPI table\n"); return -EINVAL; @@ -141,9 +141,10 @@ static int check_acpi_tpm2(struct device *dev) /* The tpm2_crb driver handles this device */ if (tbl->start_method != ACPI_TPM2_MEMORY_MAPPED) - return -ENODEV; + ret = -ENODEV; - return 0; + acpi_put_table((struct acpi_table_header *)tbl); + return ret; } #else static int check_acpi_tpm2(struct device *dev)