User: | Jiri Slaby |
Error type: | Resource Leak |
Error type description: | The code omits to put the resource to the system for reuse |
File location: | drivers/pci/search.c |
Line in file: | 207 |
Project: | Linux Kernel |
Project version: | 2.6.28 |
Tools: |
Stanse
(1.2)
|
Entered: | 2011-11-07 22:40:13 UTC |
177/** 178 * pci_get_slot - locate PCI device for a given PCI slot 179 * @bus: PCI bus on which desired PCI device resides 180 * @devfn: encodes number of PCI slot in which the desired PCI 181 * device resides and the logical device number within that slot 182 * in case of multi-function devices. 183 * 184 * Given a PCI bus and slot/function number, the desired PCI device 185 * is located in the list of PCI devices. 186 * If the device is found, its reference count is increased and this 187 * function returns a pointer to its data structure. The caller must 188 * decrement the reference count by calling pci_dev_put(). 189 * If no device is found, %NULL is returned. 190 */ 191struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn) 192{ 193 struct list_head *tmp; 194 struct pci_dev *dev; 195 196 WARN_ON(in_interrupt()); 197 down_read(&pci_bus_sem); 198 199 list_for_each(tmp, &bus->devices) { 200 dev = pci_dev_b(tmp); 201 if (dev->devfn == devfn) 202 goto out; 203 } 204 205 dev = NULL; 206 out: 207 pci_dev_get(dev); 208 up_read(&pci_bus_sem); 209 return dev; 210} 211 212/** 213 * pci_get_bus_and_slot - locate PCI device from a given PCI bus & slot 214 * @bus: number of PCI bus on which desired PCI device resides 215 * @devfn: encodes number of PCI slot in which the desired PCI 216 * device resides and the logical device number within that slot 217 * in case of multi-function devices.