From patchwork Thu Dec 2 15:33:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Assmann X-Patchwork-Id: 374831 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB2FYeft021999 for ; Thu, 2 Dec 2010 15:35:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932184Ab0LBPe7 (ORCPT ); Thu, 2 Dec 2010 10:34:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22986 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932118Ab0LBPe6 (ORCPT ); Thu, 2 Dec 2010 10:34:58 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB2FXdMo018467 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Dec 2010 10:33:41 -0500 Received: from localhost6.localdomain6 (vpn2-8-127.ams2.redhat.com [10.36.8.127]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB2FXa31023627; Thu, 2 Dec 2010 10:33:36 -0500 Date: Thu, 2 Dec 2010 10:33:36 -0500 From: Stefan Assmann To: linux-acpi@vger.kernel.org Cc: linux-pci@vger.kernel.org, jbarnes@virtuousgeek.org, JBeulich@novell.com, Olaf.Dabrunz@gmx.net, Stefan Assmann , mingo@elte.hu, bjorn.helgaas@hp.com, tglx@linutronix.de, lenb@kernel.org Message-Id: <20101202153402.29125.63713.sendpatchset@localhost6.localdomain6> In-Reply-To: <20101202153344.29125.86670.sendpatchset@localhost6.localdomain6> References: <20101202153344.29125.86670.sendpatchset@localhost6.localdomain6> Subject: [PATCH 2/5 v2] ACPI: make acpi_pci_irq_find_prt_entry return a copy of a prt_entry X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 02 Dec 2010 15:35:00 +0000 (UTC) diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 3bc2164..e1632b2 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -60,7 +60,7 @@ static inline char pin_name(int pin) static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(struct pci_dev *dev, int pin) { - struct acpi_prt_entry *entry; + struct acpi_prt_entry *entry, *entry_copy; int segment = pci_domain_nr(dev->bus); int bus = dev->bus->number; int device = PCI_SLOT(dev->devfn); @@ -72,7 +72,11 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(struct pci_dev *dev, && (device == entry->id.device) && (pin == entry->pin)) { spin_unlock(&acpi_prt_lock); - return entry; + entry_copy = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); + if (!entry_copy) + return NULL; + memcpy(entry_copy, entry, sizeof(struct acpi_prt_entry)); + return entry_copy; } } spin_unlock(&acpi_prt_lock); @@ -384,6 +388,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) &link); else gsi = entry->index; + kfree(entry); } else gsi = -1; @@ -453,6 +458,8 @@ void acpi_pci_irq_disable(struct pci_dev *dev) else gsi = entry->index; + if (entry) + kfree(entry); /* * TBD: It might be worth clearing dev->irq by magic constant * (e.g. PCI_UNDEFINED_IRQ).