From: Stefan Assmann <sassmann@redhat.com>
To: linux-acpi@vger.kernel.org
Cc: linux-pci@vger.kernel.org, jbarnes@virtuousgeek.org,
JBeulich@novell.com, Olaf.Dabrunz@gmx.net,
Stefan Assmann <sassmann@redhat.com>,
mingo@elte.hu, bjorn.helgaas@hp.com, tglx@linutronix.de,
lenb@kernel.org
Subject: [PATCH 2/5 v2] ACPI: make acpi_pci_irq_find_prt_entry return a copy of a prt_entry
Date: Thu, 2 Dec 2010 10:33:36 -0500 [thread overview]
Message-ID: <20101202153402.29125.63713.sendpatchset@localhost6.localdomain6> (raw)
In-Reply-To: <20101202153344.29125.86670.sendpatchset@localhost6.localdomain6>
From: Stefan Assmann <sassmann@redhat.com>
By returning a pointer to a copy of struct acpi_prt_entry in
acpi_pci_irq_find_prt_entry() the calling code may modify the returned
structure without altering entries in the global acpi_prt_list. Thus the
changes to acpi_prt_entry by the boot interrupt reroute code won't change the
original PRT entries.
Currently there are only two calls for acpi_pci_irq_find_prt_entry() and both
are in acpi_pci_irq_lookup(). acpi_pci_irq_lookup() itself is used only by
acpi_pci_irq_enable() and acpi_pci_irq_disable() so both are also updated to
free the copy of struct acpi_prt_entry appropriately.
Signed-off-by: Stefan Assmann <sassmann@redhat.com>
---
drivers/acpi/pci_irq.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
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).
--
1.7.3.2
next prev parent reply other threads:[~2010-12-02 15:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-02 15:33 [PATCH 0/5 v2] x86: boot interrupt reroute fix Stefan Assmann
2010-12-02 15:33 ` [PATCH 1/5 v2] ACPI: move struct acpi_prt_entry to actbl1.h Stefan Assmann
2010-12-02 15:33 ` Stefan Assmann [this message]
2010-12-02 15:33 ` [PATCH 3/5 v2] PCI: Add locking to pci_find_upstream_pcie_bridge() Stefan Assmann
2010-12-02 15:33 ` [PATCH 4/5 v2] PCI: Add header declaration for pci_find_upstream_pcie_bridge() Stefan Assmann
2010-12-02 15:34 ` [PATCH 5/5 v2] PCI, ACPI: re-add boot interrupt reroute code in separate files Stefan Assmann
2010-12-09 15:19 ` [PATCH 0/5 v2] x86: boot interrupt reroute fix Stefan Assmann
2011-01-11 10:38 ` Stefan Assmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101202153402.29125.63713.sendpatchset@localhost6.localdomain6 \
--to=sassmann@redhat.com \
--cc=JBeulich@novell.com \
--cc=Olaf.Dabrunz@gmx.net \
--cc=bjorn.helgaas@hp.com \
--cc=jbarnes@virtuousgeek.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox