From patchwork Fri Jun 4 21:25:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Kaneda X-Patchwork-Id: 12300827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3BCEC48BCF for ; Fri, 4 Jun 2021 22:01:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FFFD61415 for ; Fri, 4 Jun 2021 22:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230227AbhFDWCs (ORCPT ); Fri, 4 Jun 2021 18:02:48 -0400 Received: from mga06.intel.com ([134.134.136.31]:62965 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231199AbhFDWCq (ORCPT ); Fri, 4 Jun 2021 18:02:46 -0400 IronPort-SDR: QbM7DMNjnnRDWjm0SCgsWaz3QmwV86uFrqE8XuwiEr7pTlnlqJHHj9kgQP0RFk5Qcg/QTIgVDA GGOj06flFM5g== X-IronPort-AV: E=McAfee;i="6200,9189,10005"; a="265539943" X-IronPort-AV: E=Sophos;i="5.83,249,1616482800"; d="scan'208";a="265539943" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2021 15:00:55 -0700 IronPort-SDR: ejh6YQ5phmyKeAhM94xK0Sppxm4OQNweM3Mb4vyK3NFnSXE/2w6jP6k6LO78LdDtNsTyrhsh+c 8KEKHM4SKK6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,249,1616482800"; d="scan'208";a="634146703" Received: from sibelius.jf.intel.com ([10.54.75.166]) by fmsmga006.fm.intel.com with ESMTP; 04 Jun 2021 15:00:55 -0700 From: Erik Kaneda To: "Rafael J . Wysocki" , ACPI Devel Maling List Cc: Erik Kaneda , Shawn Guo , Bob Moore Subject: [PATCH 03/14] ACPICA: Fix memory leak caused by _CID repair function Date: Fri, 4 Jun 2021 14:25:57 -0700 Message-Id: <20210604212608.2604267-4-erik.kaneda@intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210604212608.2604267-1-erik.kaneda@intel.com> References: <20210604212608.2604267-1-erik.kaneda@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org ACPICA commit 180cb53963aa876c782a6f52cc155d951b26051a According to the ACPI spec, _CID returns a package containing hardware ID's. Each element of an ASL package contains a reference count from the parent package as well as the element itself. Name (TEST, Package() { "String object" // this package element has a reference count of 2 }) A memory leak was caused in the _CID repair function because it did not decrement the reference count created by the package. Fix the memory leak by calling acpi_ut_remove_reference on _CID package elements that represent a hardware ID (_HID). Link: https://github.com/acpica/acpica/commit/180cb539 Tested-by: Shawn Guo Signed-off-by: Erik Kaneda Signed-off-by: Bob Moore --- drivers/acpi/acpica/nsrepair2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c index 14b71b41e845..38e10ab976e6 100644 --- a/drivers/acpi/acpica/nsrepair2.c +++ b/drivers/acpi/acpica/nsrepair2.c @@ -379,6 +379,13 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info, (*element_ptr)->common.reference_count = original_ref_count; + + /* + * The original_element holds a reference from the package object + * that represents _HID. Since a new element was created by _HID, + * remove the reference from the _CID package. + */ + acpi_ut_remove_reference(original_element); } element_ptr++;