Skip to contentSkip to conversation

pci: bugfix, pci_get_domain_bus_and_slot() needs to inc reference count

PATCH In review Liu Ping Fan 2 participants 3 messages Aug 12, 2014 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: bugfix, pci_get_domain_bus_and_slot() needs to inc reference count

As the notes of this function, pci_get_domain_bus_and_slot() should increase the reference count.

---
 drivers/pci/search.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/search.c +3 -1
index 827ad83..41a5738 100644
@@ -258,8 +258,10 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 
 	for_each_pci_dev(dev) {
 		if (pci_domain_nr(dev->bus) == domain &&
-		    (dev->bus->number == bus && dev->devfn == devfn))
+		    (dev->bus->number == bus && dev->devfn == devfn)) {
+			pci_dev_get(dev);
 			return dev;
+		}
 	}
 	return NULL;
 }
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 2 lines · Liu Ping Fan

As the notes of this function, pci_get_domain_bus_and_slot() should increase the reference count.

It had did it.
please refer to:

#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)

Quoted 23 lines
---
 drivers/pci/search.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/search.c +3 -1
index 827ad83..41a5738 100644
@@ -258,8 +258,10 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 
 	for_each_pci_dev(dev) {
 		if (pci_domain_nr(dev->bus) == domain &&
-		    (dev->bus->number == bus && dev->devfn == devfn))
+		    (dev->bus->number == bus && dev->devfn == devfn)) {
+			pci_dev_get(dev);
 			return dev;
+		}
 	}
 	return NULL;
 }
Signature · 2 lines
Thanks!
Yijing
#2 lore raw
Quoted 9 lines · Yijing Wang
Quoted 2 lines · Liu Ping Fan

As the notes of this function, pci_get_domain_bus_and_slot() should increase the reference count.

It had did it.
please refer to:

#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)

Oh, got it.

Thx!

Quoted 29 lines
Quoted 13 lines
---
 drivers/pci/search.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/search.c +0 -0
index 827ad83..41a5738 100644
@@ -258,8 +258,10 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 

drivers/pci/search.c struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus, · line 267

Quoted 10 lines
drivers/pci/search.c +3 -1
      for_each_pci_dev(dev) {
              if (pci_domain_nr(dev->bus) == domain &&
-                 (dev->bus->number == bus && dev->devfn == devfn))
+                 (dev->bus->number == bus && dev->devfn == devfn)) {
+                     pci_dev_get(dev);
                      return dev;
+             }
      }
      return NULL;
 }

--
Thanks!
Yijing