Replace pci_find_device with pci_get_device, and use pci_dev_get and
authorIan Abbott <abbotti@mev.co.uk>
Wed, 27 Jun 2007 10:54:55 +0000 (10:54 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Wed, 27 Jun 2007 10:54:55 +0000 (10:54 +0000)
pci_dev_put to manage reference count for pci device.

Also, check result of kmalloc in pci_card_list_init.

comedi/drivers/icp_multi.h

index 0472b15ff62b332f7a893a43af884c6827102841..5ab59b04c3f4063033f9220a5cf3d3bae807278f 100644 (file)
@@ -60,13 +60,18 @@ static void pci_card_list_init(unsigned short pci_vendor, char display)
        inova_devices=NULL;
        last=NULL;
        
-       for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; 
-               pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+       for(pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; 
+               pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
                if(pcidev->vendor==pci_vendor){
                        inova=kmalloc(sizeof(*inova),GFP_KERNEL);
+                       if(!inova){
+                               printk("icp_multi: pci_card_list_init: allocation failed\n");
+                               pci_dev_put(pcidev);
+                               break;
+                       }
                        memset(inova,0,sizeof(*inova));
 
-                       inova->pcidev=pcidev;
+                       inova->pcidev=pci_dev_get(pcidev);
                        if (last) { last->next=inova; }
                             else { inova_devices=inova; }
                        last=inova;
@@ -100,7 +105,8 @@ static void pci_card_list_cleanup(unsigned short pci_vendor)
        struct pcilst_struct *inova,*next;
 
        for(inova=inova_devices; inova; inova=next){
-               next=inova->next;
+               next=inova->next;
+               pci_dev_put(inova->pcidev);
                kfree(inova);
        }