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: hejunhao X-Patchwork-Id: 135706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:3f2:4152:657d with SMTP id x8csp789814vqo; Tue, 15 Aug 2023 17:53:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtLEkFHbpI70BSZwMwiSd35K8c/evbqmpb5ua2+zyGx/ngtkmxDDDSjVDI6EEuqHxMkvm9 X-Received: by 2002:a17:903:444:b0:1b8:7483:d488 with SMTP id iw4-20020a170903044400b001b87483d488mr394665plb.57.1692147231510; Tue, 15 Aug 2023 17:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692147231; cv=none; d=google.com; s=arc-20160816; b=tJ6v50FXinfQ3h80S0D7m++8ZPcDpLsNJCDoF0MDReDCHe1d3Twbzuy/KyTRKFnfok LVjQMPcxbTF6wPDnFSDtgtBNagEghJ8uBg4Nf7uB5iQtFVaGI0lfkEvYH73aJDF8u+O7 i9KK6NhvUT8Ng/DExEDiYOgP9e92dlGi8szeISOCEW9xExjY7QoUumhHaKU2w22OwCcK bPMGYSsuUkBT2YEt2TMk7dV1a7gEag46i4gJhLPemxLIpUjFWemkvUvHygENao8yQgGs BcWLEw3ZsV5WNZpSKQ/o4t83ItseY6oYjZ7zoIWzHImhsfQJoyU2txyZ4AQ4DFkTp7Hh LShQ== 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=vWisccKvrheO6E7URFj3vnPItHZ4CK3J0MgVJBpRCv4=; fh=eW9sXTggpGrP9Q0O+YDZlRtemEU7E2tQ/2EK8hEEmXs=; b=rout3v8cjSsI9b2lqZVU9CsSfs7uj6kq8uPaTPE9r08zgQdKHvafq+J2aBnru7iFJZ AtPCd2gXUfCcXaGmAvQqfpzZsCDL4foa01oIgKHAO4E81TdFltXt/zgznnFRxatPenLf 99UNeeMAY92EAsrrLxD3Z41OHFZ6ULoJfo/jrKLOICr7ZPuv9grHw7QLLuOiZeCo0w6F wBqX3QxYVJ+v9NunQClU2xp3Cxn4+oIgT0WNvGIBYwaNtdixGKHPGevEN+LBnCyTGYyO 21fFRQ93FsIcK/ndsMXwE6UhWkhGuoep9pV2N4WMZ0J7oJHxNaW8dqXYk4BUc5EshTle mzQg== 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 s9-20020a170902ea0900b001b8a70d11e4si10720725plg.529.2023.08.15.17.53.23; Tue, 15 Aug 2023 17:53:51 -0700 (PDT) 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 S237215AbjHOMbj (ORCPT + 99 others); Tue, 15 Aug 2023 08:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236123AbjHOMa6 (ORCPT ); Tue, 15 Aug 2023 08:30:58 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B59AB1980 for ; Tue, 15 Aug 2023 05:30:56 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1774344975608438047 X-GMAIL-MSGID: 1774344975608438047 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; }