]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/hotplug/ibmphp_core.c
PCI hotplug: ibmphp: Fix module ref count underflow
[linux-2.6-omap-h63xx.git] / drivers / pci / hotplug / ibmphp_core.c
index 87b6b8b280e65024fe112e06f1fe59e75a297aeb..633e743442ac711d0b02d6b85a8252a1ee74dbb5 100644 (file)
@@ -148,8 +148,10 @@ int ibmphp_init_devno(struct slot **cur_slot)
        len = (rtable->size - sizeof(struct irq_routing_table)) /
                        sizeof(struct irq_info);
 
-       if (!len)
+       if (!len) {
+               kfree(rtable);
                return -1;
+       }
        for (loop = 0; loop < len; loop++) {
                if ((*cur_slot)->number == rtable->slots[loop].slot) {
                if ((*cur_slot)->bus == rtable->slots[loop].bus) {
@@ -187,11 +189,13 @@ int ibmphp_init_devno(struct slot **cur_slot)
                                debug("rtable->slots[loop].irq[3].link = %x\n",
                                        rtable->slots[loop].irq[3].link);
                                debug("end of init_devno\n");
+                               kfree(rtable);
                                return 0;
                        }
                }
        }
 
+       kfree(rtable);
        return -1;
 }
 
@@ -395,7 +399,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
        struct slot *pslot;
        u8 mode = 0;
 
-       debug("%s - Entry hotplug_slot[%p] pvalue[%p]\n", __FUNCTION__,
+       debug("%s - Entry hotplug_slot[%p] pvalue[%p]\n", __func__,
                hotplug_slot, value);
 
        ibmphp_lock_operations();
@@ -425,7 +429,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
        }
 
        ibmphp_unlock_operations();
-       debug("%s - Exit rc[%d] value[%x]\n", __FUNCTION__, rc, *value);
+       debug("%s - Exit rc[%d] value[%x]\n", __func__, rc, *value);
        return rc;
 }
 
@@ -435,7 +439,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
        struct slot *pslot;
        u8 mode = 0;
 
-       debug("%s - Entry hotplug_slot[%p] pvalue[%p]\n", __FUNCTION__,
+       debug("%s - Entry hotplug_slot[%p] pvalue[%p]\n", __func__,
                hotplug_slot, value);
 
        ibmphp_lock_operations();
@@ -471,7 +475,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
        }
 
        ibmphp_unlock_operations();
-       debug("%s - Exit rc[%d] value[%x]\n", __FUNCTION__, rc, *value);
+       debug("%s - Exit rc[%d] value[%x]\n", __func__, rc, *value);
        return rc;
 }
 
@@ -741,13 +745,13 @@ static void free_slots(void)
        struct list_head * tmp;
        struct list_head * next;
 
-       debug("%s -- enter\n", __FUNCTION__);
+       debug("%s -- enter\n", __func__);
 
        list_for_each_safe(tmp, next, &ibmphp_slot_head) {
                slot_cur = list_entry(tmp, struct slot, ibm_slot_list);
                pci_hp_deregister(slot_cur->hotplug_slot);
        }
-       debug("%s -- exit\n", __FUNCTION__);
+       debug("%s -- exit\n", __func__);
 }
 
 static void ibm_unconfigure_device(struct pci_func *func)
@@ -755,7 +759,7 @@ static void ibm_unconfigure_device(struct pci_func *func)
        struct pci_dev *temp;
        u8 j;
 
-       debug("inside %s\n", __FUNCTION__);
+       debug("inside %s\n", __func__);
        debug("func->device = %x, func->function = %x\n",
                                        func->device, func->function);
        debug("func->device << 3 | 0x0  = %x\n", func->device << 3 | 0x0);
@@ -786,13 +790,13 @@ static u8 bus_structure_fixup(u8 busno)
 
        bus = kmalloc(sizeof(*bus), GFP_KERNEL);
        if (!bus) {
-               err("%s - out of memory\n", __FUNCTION__);
+               err("%s - out of memory\n", __func__);
                return 1;
        }
        dev = kmalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev) {
                kfree(bus);
-               err("%s - out of memory\n", __FUNCTION__);
+               err("%s - out of memory\n", __func__);
                return 1;
        }
 
@@ -803,7 +807,7 @@ static u8 bus_structure_fixup(u8 busno)
                if (!pci_read_config_word(dev, PCI_VENDOR_ID, &l) &&
                                        (l != 0x0000) && (l != 0xffff)) {
                        debug("%s - Inside bus_struture_fixup()\n",
-                                                       __FUNCTION__);
+                                                       __func__);
                        pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL);
                        break;
                }
@@ -900,7 +904,7 @@ static int set_bus(struct slot * slot_cur)
                { },
        };      
 
-       debug("%s - entry slot # %d\n", __FUNCTION__, slot_cur->number);
+       debug("%s - entry slot # %d\n", __func__, slot_cur->number);
        if (SET_BUS_STATUS(slot_cur->ctrl) && is_bus_empty(slot_cur)) {
                rc = slot_update(&slot_cur);
                if (rc)
@@ -975,7 +979,7 @@ static int set_bus(struct slot * slot_cur)
        /* This is for x440, once Brandon fixes the firmware, 
        will not need this delay */
        msleep(1000);
-       debug("%s -Exit\n", __FUNCTION__);
+       debug("%s -Exit\n", __func__);
        return 0;
 }
 
@@ -1398,10 +1402,6 @@ static int __init ibmphp_init(void)
                goto error;
        }
 
-       /* lock ourselves into memory with a module 
-        * count of -1 so that no one can unload us. */
-       module_put(THIS_MODULE);
-
 exit:
        return rc;
 
@@ -1419,4 +1419,3 @@ static void __exit ibmphp_exit(void)
 }
 
 module_init(ibmphp_init);
-module_exit(ibmphp_exit);