Commit a0347d12 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] PCI Hotplug: dereference null variable cleanup patches.

These were pointed out by "dan carpenter" <error27@email.com>
from his smatch tool.
parent 5ad0c942
...@@ -395,6 +395,8 @@ static int cpci_configure_bridge(struct pci_bus* bus, struct pci_dev* dev) ...@@ -395,6 +395,8 @@ static int cpci_configure_bridge(struct pci_bus* bus, struct pci_dev* dev)
/* Scan behind bridge */ /* Scan behind bridge */
n = pci_scan_bridge(bus, dev, max, 2); n = pci_scan_bridge(bus, dev, max, 2);
child = pci_find_bus(max + 1); child = pci_find_bus(max + 1);
if (!child)
return -ENODEV;
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
pci_proc_attach_bus(child); pci_proc_attach_bus(child);
#endif #endif
......
...@@ -488,6 +488,8 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl ...@@ -488,6 +488,8 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl
bridgeSlot = 0xFF; bridgeSlot = 0xFF;
PCIIRQRoutingInfoLength = pcibios_get_irq_routing_table(); PCIIRQRoutingInfoLength = pcibios_get_irq_routing_table();
if (!PCIIRQRoutingInfoLength)
return -1;
len = (PCIIRQRoutingInfoLength->size - len = (PCIIRQRoutingInfoLength->size -
sizeof(struct irq_routing_table)) / sizeof(struct irq_info); sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
......
...@@ -188,6 +188,8 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl) ...@@ -188,6 +188,8 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
rc++; rc++;
p_slot = find_slot(ctrl, hp_slot + (readb(ctrl->hpc_reg + SLOT_MASK) >> 4)); p_slot = find_slot(ctrl, hp_slot + (readb(ctrl->hpc_reg + SLOT_MASK) >> 4));
if (!p_slot)
return 0;
// If the switch closed, must be a button // If the switch closed, must be a button
// If not in button mode, nevermind // If not in button mode, nevermind
...@@ -1799,8 +1801,12 @@ static void interrupt_event_handler(struct controller *ctrl) ...@@ -1799,8 +1801,12 @@ static void interrupt_event_handler(struct controller *ctrl)
hp_slot = ctrl->event_queue[loop].hp_slot; hp_slot = ctrl->event_queue[loop].hp_slot;
func = cpqhp_slot_find(ctrl->bus, (hp_slot + ctrl->slot_device_offset), 0); func = cpqhp_slot_find(ctrl->bus, (hp_slot + ctrl->slot_device_offset), 0);
if (!func)
return;
p_slot = find_slot(ctrl, hp_slot + ctrl->slot_device_offset); p_slot = find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
if (!p_slot)
return;
dbg("hp_slot %d, func %p, p_slot %p\n", dbg("hp_slot %d, func %p, p_slot %p\n",
hp_slot, func, p_slot); hp_slot, func, p_slot);
...@@ -2511,8 +2517,14 @@ static int configure_new_function (struct controller * ctrl, struct pci_func * f ...@@ -2511,8 +2517,14 @@ static int configure_new_function (struct controller * ctrl, struct pci_func * f
// Setup the IO, memory, and prefetchable windows // Setup the IO, memory, and prefetchable windows
io_node = get_max_resource(&(resources->io_head), 0x1000); io_node = get_max_resource(&(resources->io_head), 0x1000);
if (!io_node)
return -ENOMEM;
mem_node = get_max_resource(&(resources->mem_head), 0x100000); mem_node = get_max_resource(&(resources->mem_head), 0x100000);
if (!mem_node)
return -ENOMEM;
p_mem_node = get_max_resource(&(resources->p_mem_head), 0x100000); p_mem_node = get_max_resource(&(resources->p_mem_head), 0x100000);
if (!p_mem_node)
return -ENOMEM;
dbg("Setup the IO, memory, and prefetchable windows\n"); dbg("Setup the IO, memory, and prefetchable windows\n");
dbg("io_node\n"); dbg("io_node\n");
dbg("(base, len, next) (%x, %x, %p)\n", io_node->base, io_node->length, io_node->next); dbg("(base, len, next) (%x, %x, %p)\n", io_node->base, io_node->length, io_node->next);
......
...@@ -435,6 +435,8 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num ...@@ -435,6 +435,8 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num
u8 tbus, tdevice, tslot; u8 tbus, tdevice, tslot;
PCIIRQRoutingInfoLength = pcibios_get_irq_routing_table(); PCIIRQRoutingInfoLength = pcibios_get_irq_routing_table();
if (!PCIIRQRoutingInfoLength)
return -1;
len = (PCIIRQRoutingInfoLength->size - len = (PCIIRQRoutingInfoLength->size -
sizeof(struct irq_routing_table)) / sizeof(struct irq_info); sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
......
...@@ -113,6 +113,8 @@ static int read_dev (char *buf, char **start, off_t offset, int len, int *eof, v ...@@ -113,6 +113,8 @@ static int read_dev (char *buf, char **start, off_t offset, int len, int *eof, v
while (slot) { while (slot) {
new_slot = cpqhp_slot_find(slot->bus, slot->device, 0); new_slot = cpqhp_slot_find(slot->bus, slot->device, 0);
if (!new_slot)
break;
out += sprintf(out, "assigned resources: memory\n"); out += sprintf(out, "assigned resources: memory\n");
index = 11; index = 11;
res = new_slot->mem_head; res = new_slot->mem_head;
......
...@@ -1057,6 +1057,8 @@ static int ibm_configure_device (struct pci_func *func) ...@@ -1057,6 +1057,8 @@ static int ibm_configure_device (struct pci_func *func)
if (func->dev == NULL) { if (func->dev == NULL) {
dev0.bus = ibmphp_find_bus (func->busno); dev0.bus = ibmphp_find_bus (func->busno);
if (!dev0.bus)
return 0;
dev0.devfn = ((func->device << 3) + (func->function & 0x7)); dev0.devfn = ((func->device << 3) + (func->function & 0x7));
dev0.sysdata = dev0.bus->sysdata; dev0.sysdata = dev0.bus->sysdata;
...@@ -1097,6 +1099,8 @@ static int is_bus_empty (struct slot * slot_cur) ...@@ -1097,6 +1099,8 @@ static int is_bus_empty (struct slot * slot_cur)
continue; continue;
} }
tmp_slot = ibmphp_get_slot_from_physical_num (i); tmp_slot = ibmphp_get_slot_from_physical_num (i);
if (!tmp_slot)
return 0;
rc = slot_update (&tmp_slot); rc = slot_update (&tmp_slot);
if (rc) if (rc)
return 0; return 0;
...@@ -1219,6 +1223,8 @@ static int check_limitations (struct slot *slot_cur) ...@@ -1219,6 +1223,8 @@ static int check_limitations (struct slot *slot_cur)
for (i = slot_cur->bus_on->slot_min; i <= slot_cur->bus_on->slot_max; i++) { for (i = slot_cur->bus_on->slot_min; i <= slot_cur->bus_on->slot_max; i++) {
tmp_slot = ibmphp_get_slot_from_physical_num (i); tmp_slot = ibmphp_get_slot_from_physical_num (i);
if (!tmp_slot)
return -ENODEV;
if ((SLOT_PWRGD (tmp_slot->status)) && !(SLOT_CONNECT (tmp_slot->status))) if ((SLOT_PWRGD (tmp_slot->status)) && !(SLOT_CONNECT (tmp_slot->status)))
count++; count++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment