[PATCH 11/9] pci/msi: make attach_msi_entry() more meaningful

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move setting entry->dev to inside of attach_msi_entry().
OTOH, free_msi_entries() can validate attached entry by checking
entry->dev, whether it was attached in proper way.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@xxxxxxxxxxxxxx>
---
 drivers/pci/msi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 872d61b..885fc20 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -261,6 +261,7 @@ static void free_msi_entries(struct pci_dev *dev)
 	struct msi_desc *entry, *tmp;
 
 	list_for_each_entry(entry, &dev->msi_list, list) {
+		BUG_ON(!entry || !entry->dev || entry->dev != dev);
 		if (entry->irq)
 			BUG_ON(irq_has_action(entry->irq));
 	}
@@ -283,6 +284,7 @@ static void free_msi_entries(struct pci_dev *dev)
 
 static void attach_msi_entry(struct pci_dev *dev, struct msi_desc *entry)
 {
+	entry->dev = dev;
 	list_add_tail(&entry->list, &dev->msi_list);
 }
 
@@ -402,7 +404,6 @@ static int msi_capability_init(struct pci_dev *dev)
 	entry->msi_attrib.masked = 1;
 	entry->msi_attrib.default_irq = dev->irq;	/* Save IOAPIC IRQ */
 	entry->msi_attrib.pos = pos;
-	entry->dev = dev;
 	if (entry->msi_attrib.maskbit) {
 		unsigned int base, maskbits, temp;
 
@@ -487,7 +488,6 @@ static int msix_capability_init(struct pci_dev *dev,
 		entry->msi_attrib.masked = 1;
 		entry->msi_attrib.default_irq = dev->irq;
 		entry->msi_attrib.pos = pos;
-		entry->dev = dev;
 		entry->mask_base = base;
 
 		attach_msi_entry(dev, entry);
-- 
1.5.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux