diff mbox

[2/4] ACPI: make acpi_pci_irq_find_prt_entry return a copy of a prt_entry

Message ID 20101118135227.2269.72184.sendpatchset@localhost6.localdomain6 (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Assmann Nov. 18, 2010, 1:52 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 3bc2164..02202a2 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).