From patchwork Tue Aug 15 12:28:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junhao He X-Patchwork-Id: 13353793 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 327E1C001B0 for ; Tue, 15 Aug 2023 12:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CrbZjz9LCOwGZcNsWlsxdQMTsotHclrjDBk7cj8SjEY=; b=imdBx793G9xaWO Ffqkjkg5EyMaogTlOs60W3PK5fPbxLvpjEMDT2106ioAxdt/GdrMtTh8KaWPsWubEEEzx7RetS1n6 N2TV1nwEWasw6Gcx/HvSNYxwdShCycQuRYG2nHn43wH2GeDYiED/+eHoT6VhlqApSmFGmE/ZqCnpm wYSgawjtjQ5Hrw6ChfWfgYDwzPM6lPH03gNxdBA7mmBKAXYpJI42XEXlL9A6SJLFs15G9vGyY72Ff U0T6+5ymYjwBuismlNEwNOP6BZgjIna6vMJojpfW2qTjazKaVJlkSYnsjF1BoxrWA9M/gkE68dSEF qPu+QEnDEM7bqi5QDN7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVtCS-001boh-2K; Tue, 15 Aug 2023 12:31:04 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qVtCQ-001bns-0A for linux-arm-kernel@lists.infradead.org; Tue, 15 Aug 2023 12:31:03 +0000 Received: from dggpeml500002.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RQ9XG3LMBzFqfB; Tue, 15 Aug 2023 20:27:58 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpeml500002.china.huawei.com (7.185.36.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 20:30:54 +0800 From: Junhao He To: , , , CC: , , , , , , , Subject: [PATCH 1/1] coresight: Fix the ACPI memory leak Date: Tue, 15 Aug 2023 20:28:03 +0800 Message-ID: <20230815122803.29295-1-hejunhao3@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500002.china.huawei.com (7.185.36.158) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230815_053102_260516_27D87014 X-CRM114-Status: GOOD ( 11.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The ACPI buffer memory (buf.pointer) should be freed as the buffer is not used after returning from acpi_get_dsd_graph(), free it to prevent memory leak. Fixes: 76ffa5ab5b79 ("coresight: Support for ACPI bindings") Signed-off-by: Junhao He --- drivers/hwtracing/coresight/coresight-platform.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 3e2e135cb8f6..c61cac5e058e 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -524,12 +524,15 @@ acpi_get_dsd_graph(struct acpi_device *adev) /* Skip the non-Graph _DSD packages */ if (!is_acpi_dsd_graph_guid(guid)) continue; - if (acpi_validate_dsd_graph(package)) + if (acpi_validate_dsd_graph(package)) { + ACPI_FREE(buf.pointer); return package; + } /* Invalid graph format, continue */ dev_warn(&adev->dev, "Invalid Graph _DSD property\n"); } + ACPI_FREE(buf.pointer); return NULL; }