From patchwork Wed Nov 25 20:19:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 7702831 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BF84B9F2E9 for ; Wed, 25 Nov 2015 20:20:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2CE720821 for ; Wed, 25 Nov 2015 20:20:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D36E7207E1 for ; Wed, 25 Nov 2015 20:20:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751675AbbKYUUX (ORCPT ); Wed, 25 Nov 2015 15:20:23 -0500 Received: from mailout2.hostsharing.net ([83.223.90.233]:53689 "EHLO mailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750734AbbKYUUW (ORCPT ); Wed, 25 Nov 2015 15:20:22 -0500 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout2.hostsharing.net (Postfix) with ESMTPS id C33E81008C299; Wed, 25 Nov 2015 21:20:21 +0100 (CET) Received: from localhost (6-38-90-81.adsl.cmo.de [81.90.38.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id 9C333603E044; Wed, 25 Nov 2015 21:20:20 +0100 (CET) X-Mailbox-Line: From 994278b96189033970d0a2add95645110c716fbb Mon Sep 17 00:00:00 2001 Message-Id: <994278b96189033970d0a2add95645110c716fbb.1448480385.git.lukas@wunner.de> In-Reply-To: References: From: Lukas Wunner Date: Wed, 25 Nov 2015 21:19:55 +0100 Subject: [PATCH v2 1/2] ACPI / scan: Fix acpi_bus_id_list bookkeeping To: linux-acpi@vger.kernel.org, "Rafael J. Wysocki" , Len Brown Cc: devel@acpica.org, Hanjun Guo , Robert Moore , Mark Brown , Hui Wang , Darren Hart Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP acpi_device_add() allocates and adds an element to acpi_bus_id_list (or increments the instance count if the device's HID is already present in the list), but the element is never deleted from the list nor freed. Fix it. Signed-off-by: Lukas Wunner --- drivers/acpi/scan.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 78d5f02..a0e942b 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -471,10 +471,24 @@ static void acpi_device_release(struct device *dev) static void acpi_device_del(struct acpi_device *device) { + struct acpi_device_bus_id *acpi_device_bus_id; + mutex_lock(&acpi_device_lock); if (device->parent) list_del(&device->node); + list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) + if (!strcmp(acpi_device_bus_id->bus_id, + acpi_device_hid(device))) { + if (acpi_device_bus_id->instance_no > 0) + acpi_device_bus_id->instance_no--; + else { + list_del(&acpi_device_bus_id->node); + kfree(acpi_device_bus_id); + } + break; + } + list_del(&device->wakeup_list); mutex_unlock(&acpi_device_lock);