From patchwork Wed Apr 28 22:52:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Kaneda X-Patchwork-Id: 12230237 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,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 72598C433ED for ; Wed, 28 Apr 2021 23:27:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44567613FA for ; Wed, 28 Apr 2021 23:27:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229624AbhD1X2X (ORCPT ); Wed, 28 Apr 2021 19:28:23 -0400 Received: from mga05.intel.com ([192.55.52.43]:56096 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbhD1X2W (ORCPT ); Wed, 28 Apr 2021 19:28:22 -0400 IronPort-SDR: ubJs5szqey04z/fGxNYdyyuJlRh1FQAXa4vCQSCbiIaE2NSJtr4RmKEDM4TPhxlR7M1gAgzJl4 7fg7mxQ7SC2A== X-IronPort-AV: E=McAfee;i="6200,9189,9968"; a="282215241" X-IronPort-AV: E=Sophos;i="5.82,258,1613462400"; d="scan'208";a="282215241" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 16:27:37 -0700 IronPort-SDR: EKrsUp3cVtERmCcKqKi6oJi4NvEYdJf5sM1YYpnApdEQ1IHFk5mXZI5Tw+wtppHXXy5ZTpUjgT 0W9VxBEEnGoQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,258,1613462400"; d="scan'208";a="466120973" Received: from sibelius.jf.intel.com ([10.54.75.166]) by orsmga001.jf.intel.com with ESMTP; 28 Apr 2021 16:27:36 -0700 From: Erik Kaneda To: "Rafael J . Wysocki" , ACPI Devel Maling List , Shawn Guo , Gordon Ross Cc: Moore@vger.kernel.org, Robert , Erik Kaneda Subject: [RFT PATCH] ACPICA: Fix memory leak caused by _CID repair function Date: Wed, 28 Apr 2021 15:52:47 -0700 Message-Id: <20210428225247.1701392-1-erik.kaneda@intel.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org ACPICA commit 5fc4f4b87d6890d48d050ab279ed01f0132662ca 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/5fc4f4b8 Signed-off-by: Erik Kaneda Tested-by: Shawn Guo --- 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++;