summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <greg@kroah.com>2003-02-06 15:15:13 +1100
committerGreg Kroah-Hartman <greg@kroah.com>2003-02-06 15:15:13 +1100
commita0347d12cfbc08ec3d8be022351c9916836c2beb (patch)
tree05cb9dfd53e1a9c4b461dd0e2b0f70d95485d8e3
parent5ad0c9427d97547b6adbde4244f9732de6ba4248 (diff)
[PATCH] PCI Hotplug: dereference null variable cleanup patches.
These were pointed out by "dan carpenter" <error27@email.com> from his smatch tool.
-rw-r--r--drivers/hotplug/cpci_hotplug_pci.c2
-rw-r--r--drivers/hotplug/cpqphp_core.c2
-rw-r--r--drivers/hotplug/cpqphp_ctrl.c12
-rw-r--r--drivers/hotplug/cpqphp_pci.c2
-rw-r--r--drivers/hotplug/cpqphp_proc.c2
-rw-r--r--drivers/hotplug/ibmphp_core.c6
6 files changed, 26 insertions, 0 deletions
diff --git a/drivers/hotplug/cpci_hotplug_pci.c b/drivers/hotplug/cpci_hotplug_pci.c
index a82a3175b7c1..da4d0d77b13b 100644
--- a/drivers/hotplug/cpci_hotplug_pci.c
+++ b/drivers/hotplug/cpci_hotplug_pci.c
@@ -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
diff --git a/drivers/hotplug/cpqphp_core.c b/drivers/hotplug/cpqphp_core.c
index aba33f1d3dff..5e641fd1c6e3 100644
--- a/drivers/hotplug/cpqphp_core.c
+++ b/drivers/hotplug/cpqphp_core.c
@@ -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);
diff --git a/drivers/hotplug/cpqphp_ctrl.c b/drivers/hotplug/cpqphp_ctrl.c
index 4086fe656f3f..eaa66efac470 100644
--- a/drivers/hotplug/cpqphp_ctrl.c
+++ b/drivers/hotplug/cpqphp_ctrl.c
@@ -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);
diff --git a/drivers/hotplug/cpqphp_pci.c b/drivers/hotplug/cpqphp_pci.c
index d0fee047e140..6b9ad77538b3 100644
--- a/drivers/hotplug/cpqphp_pci.c
+++ b/drivers/hotplug/cpqphp_pci.c
@@ -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);
diff --git a/drivers/hotplug/cpqphp_proc.c b/drivers/hotplug/cpqphp_proc.c
index e06e929e95f1..2f56047eee58 100644
--- a/drivers/hotplug/cpqphp_proc.c
+++ b/drivers/hotplug/cpqphp_proc.c
@@ -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;
diff --git a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c
index 2fec0d5c4e80..eb3a455fdb4d 100644
--- a/drivers/hotplug/ibmphp_core.c
+++ b/drivers/hotplug/ibmphp_core.c
@@ -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++;
}