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)
/* Scan behind bridge */
n = pci_scan_bridge(bus, dev, max, 2);
child = pci_find_bus(max + 1);
if (!child)
return -ENODEV;
#ifdef CONFIG_PROC_FS
pci_proc_attach_bus(child);
#endif
......
......@@ -488,6 +488,8 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl
bridgeSlot = 0xFF;
PCIIRQRoutingInfoLength = pcibios_get_irq_routing_table();
if (!PCIIRQRoutingInfoLength)
return -1;
len = (PCIIRQRoutingInfoLength->size -
sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
......
......@@ -188,6 +188,8 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
rc++;
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 not in button mode, nevermind
......@@ -1799,8 +1801,12 @@ static void interrupt_event_handler(struct controller *ctrl)
hp_slot = ctrl->event_queue[loop].hp_slot;
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);
if (!p_slot)
return;
dbg("hp_slot %d, func %p, p_slot %p\n",
hp_slot, func, p_slot);
......@@ -2511,8 +2517,14 @@ static int configure_new_function (struct controller * ctrl, struct pci_func * f
// Setup the IO, memory, and prefetchable windows
io_node = get_max_resource(&(resources->io_head), 0x1000);
if (!io_node)
return -ENOMEM;
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);
if (!p_mem_node)
return -ENOMEM;
dbg("Setup the IO, memory, and prefetchable windows\n");
dbg("io_node\n");
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
u8 tbus, tdevice, tslot;
PCIIRQRoutingInfoLength = pcibios_get_irq_routing_table();
if (!PCIIRQRoutingInfoLength)
return -1;
len = (PCIIRQRoutingInfoLength->size -
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
while (slot) {
new_slot = cpqhp_slot_find(slot->bus, slot->device, 0);
if (!new_slot)
break;
out += sprintf(out, "assigned resources: memory\n");
index = 11;
res = new_slot->mem_head;
......
......@@ -1057,6 +1057,8 @@ static int ibm_configure_device (struct pci_func *func)
if (func->dev == NULL) {
dev0.bus = ibmphp_find_bus (func->busno);
if (!dev0.bus)
return 0;
dev0.devfn = ((func->device << 3) + (func->function & 0x7));
dev0.sysdata = dev0.bus->sysdata;
......@@ -1097,6 +1099,8 @@ static int is_bus_empty (struct slot * slot_cur)
continue;
}
tmp_slot = ibmphp_get_slot_from_physical_num (i);
if (!tmp_slot)
return 0;
rc = slot_update (&tmp_slot);
if (rc)
return 0;
......@@ -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++) {
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)))
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