Commit c7abb235 authored by Markus Elfring's avatar Markus Elfring Committed by Bjorn Helgaas
Browse files

PCI: Remove unnecessary messages for memory allocation failures



Per ebfdc409 ("checkpatch: attempt to find unnecessary 'out of memory'
messages"), when a memory allocation fails, the memory subsystem emits
generic "out of memory" messages (see slab_out_of_memory() for some of this
logging).  Therefore, additional error messages in the caller don't add
much value.

Remove messages that merely report "out of memory".

This preserves some messages that report additional information, e.g.,
allocation failures that mean we drop hotplug events.

This issue was detected by using the Coccinelle software.

Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
[bhelgaas: changelog, squash patches, make similar changes to acpiphp,
cpqphp, ibmphp, keep warning when dropping hotplug event]
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent fdabc3fe
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -811,10 +811,8 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)

	handle = adev->handle;
	bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
	if (!bridge) {
		acpi_handle_err(handle, "No memory for bridge object\n");
	if (!bridge)
		return;
	}

	INIT_LIST_HEAD(&bridge->slots);
	kref_init(&bridge->ref);
+0 −1
Original line number Diff line number Diff line
@@ -883,7 +883,6 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

	ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
	if (!ctrl) {
		err("%s : out of memory\n", __func__);
		rc = -ENOMEM;
		goto err_disable_device;
	}
+3 −10
Original line number Diff line number Diff line
@@ -603,10 +603,8 @@ int ibmphp_update_slot_info(struct slot *slot_cur)
	u8 mode;

	info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
	if (!info) {
		err("out of system memory\n");
	if (!info)
		return -ENOMEM;
	}

	info->power_status = SLOT_PWRGD(slot_cur->status);
	info->attention_status = SLOT_ATTN(slot_cur->status,
@@ -734,14 +732,12 @@ static u8 bus_structure_fixup(u8 busno)
		return 1;

	bus = kmalloc(sizeof(*bus), GFP_KERNEL);
	if (!bus) {
		err("%s - out of memory\n", __func__);
	if (!bus)
		return 1;
	}

	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
	if (!dev) {
		kfree(bus);
		err("%s - out of memory\n", __func__);
		return 1;
	}

@@ -1101,7 +1097,6 @@ static int enable_slot(struct hotplug_slot *hs)
	if (!slot_cur->func) {
		/* We cannot do update_slot_info here, since no memory for
		 * kmalloc n.e.ways, and update_slot_info allocates some */
		err("out of system memory\n");
		rc = -ENOMEM;
		goto error_power;
	}
@@ -1208,7 +1203,6 @@ int ibmphp_do_disable_slot(struct slot *slot_cur)
		/* We need this for functions that were there on bootup */
		slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL);
		if (!slot_cur->func) {
			err("out of system memory\n");
			rc = -ENOMEM;
			goto error;
		}
@@ -1306,7 +1300,6 @@ static int __init ibmphp_init(void)

	ibmphp_pci_bus = kmalloc(sizeof(*ibmphp_pci_bus), GFP_KERNEL);
	if (!ibmphp_pci_bus) {
		err("out of memory\n");
		rc = -ENOMEM;
		goto exit;
	}
+20 −40
Original line number Diff line number Diff line
@@ -167,10 +167,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno)
						goto error;
					}
					newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
					if (!newfunc) {
						err("out of system memory\n");
					if (!newfunc)
						return -ENOMEM;
					}

					newfunc->busno = cur_func->busno;
					newfunc->device = device;
					cur_func->next = newfunc;
@@ -205,10 +204,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno)
					for (i = 0; i < 32; i++) {
						if (func->devices[i]) {
							newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
							if (!newfunc) {
								err("out of system memory\n");
							if (!newfunc)
								return -ENOMEM;
							}

							newfunc->busno = sec_number;
							newfunc->device = (u8) i;
							for (j = 0; j < 4; j++)
@@ -233,10 +231,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno)
					}

					newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
					if (!newfunc) {
						err("out of system memory\n");
					if (!newfunc)
						return -ENOMEM;
					}

					newfunc->busno = cur_func->busno;
					newfunc->device = device;
					for (j = 0; j < 4; j++)
@@ -279,10 +276,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno)
						if (func->devices[i]) {
							debug("inside for loop, device is %x\n", i);
							newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
							if (!newfunc) {
								err(" out of system memory\n");
							if (!newfunc)
								return -ENOMEM;
							}

							newfunc->busno = sec_number;
							newfunc->device = (u8) i;
							for (j = 0; j < 4; j++)
@@ -405,10 +401,9 @@ static int configure_device(struct pci_func *func)

			io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);

			if (!io[count]) {
				err("out of system memory\n");
			if (!io[count])
				return -ENOMEM;
			}

			io[count]->type = IO;
			io[count]->busno = func->busno;
			io[count]->devfunc = PCI_DEVFN(func->device, func->function);
@@ -442,10 +437,9 @@ static int configure_device(struct pci_func *func)
				debug("len[count] in PFMEM %x, count %d\n", len[count], count);

				pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
				if (!pfmem[count]) {
					err("out of system memory\n");
				if (!pfmem[count])
					return -ENOMEM;
				}

				pfmem[count]->type = PFMEM;
				pfmem[count]->busno = func->busno;
				pfmem[count]->devfunc = PCI_DEVFN(func->device,
@@ -458,7 +452,6 @@ static int configure_device(struct pci_func *func)
				} else {
					mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
					if (!mem_tmp) {
						err("out of system memory\n");
						kfree(pfmem[count]);
						return -ENOMEM;
					}
@@ -508,10 +501,9 @@ static int configure_device(struct pci_func *func)
				debug("len[count] in Mem %x, count %d\n", len[count], count);

				mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
				if (!mem[count]) {
					err("out of system memory\n");
				if (!mem[count])
					return -ENOMEM;
				}

				mem[count]->type = MEM;
				mem[count]->busno = func->busno;
				mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -674,7 +666,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
			bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);

			if (!bus_io[count]) {
				err("out of system memory\n");
				retval = -ENOMEM;
				goto error;
			}
@@ -706,7 +697,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)

				bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
				if (!bus_pfmem[count]) {
					err("out of system memory\n");
					retval = -ENOMEM;
					goto error;
				}
@@ -722,7 +712,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
				} else {
					mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
					if (!mem_tmp) {
						err("out of system memory\n");
						retval = -ENOMEM;
						goto error;
					}
@@ -763,7 +752,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)

				bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
				if (!bus_mem[count]) {
					err("out of system memory\n");
					retval = -ENOMEM;
					goto error;
				}
@@ -834,7 +822,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
		io = kzalloc(sizeof(*io), GFP_KERNEL);

		if (!io) {
			err("out of system memory\n");
			retval = -ENOMEM;
			goto error;
		}
@@ -856,7 +843,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
		debug("it wants %x memory behind the bridge\n", amount_needed->mem);
		mem = kzalloc(sizeof(*mem), GFP_KERNEL);
		if (!mem) {
			err("out of system memory\n");
			retval = -ENOMEM;
			goto error;
		}
@@ -878,7 +864,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
		debug("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem);
		pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL);
		if (!pfmem) {
			err("out of system memory\n");
			retval = -ENOMEM;
			goto error;
		}
@@ -893,7 +878,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
		} else {
			mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
			if (!mem_tmp) {
				err("out of system memory\n");
				retval = -ENOMEM;
				goto error;
			}
@@ -924,7 +908,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
		if (!bus) {
			bus = kzalloc(sizeof(*bus), GFP_KERNEL);
			if (!bus) {
				err("out of system memory\n");
				retval = -ENOMEM;
				goto error;
			}
@@ -1652,10 +1635,9 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re
	}
	if (io) {
		io_range = kzalloc(sizeof(*io_range), GFP_KERNEL);
		if (!io_range) {
			err("out of system memory\n");
		if (!io_range)
			return -ENOMEM;
		}

		io_range->start = io->start;
		io_range->end = io->end;
		io_range->rangeno = 1;
@@ -1664,10 +1646,9 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re
	}
	if (mem) {
		mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL);
		if (!mem_range) {
			err("out of system memory\n");
		if (!mem_range)
			return -ENOMEM;
		}

		mem_range->start = mem->start;
		mem_range->end = mem->end;
		mem_range->rangeno = 1;
@@ -1676,10 +1657,9 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re
	}
	if (pfmem) {
		pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL);
		if (!pfmem_range) {
			err("out of system memory\n");
		if (!pfmem_range)
			return -ENOMEM;
		}

		pfmem_range->start = pfmem->start;
		pfmem_range->end = pfmem->end;
		pfmem_range->rangeno = 1;
+13 −25
Original line number Diff line number Diff line
@@ -56,10 +56,8 @@ static struct bus_node * __init alloc_error_bus(struct ebda_pci_rsrc *curr, u8 b
	}

	newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
	if (!newbus) {
		err("out of system memory\n");
	if (!newbus)
		return NULL;
	}

	if (flag)
		newbus->busno = busno;
@@ -79,10 +77,9 @@ static struct resource_node * __init alloc_resources(struct ebda_pci_rsrc *curr)
	}

	rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
	if (!rs) {
		err("out of system memory\n");
	if (!rs)
		return NULL;
	}

	rs->busno = curr->bus_num;
	rs->devfunc = curr->dev_fun;
	rs->start = curr->start_addr;
@@ -99,10 +96,9 @@ static int __init alloc_bus_range(struct bus_node **new_bus, struct range_node *

	if (first_bus) {
		newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
		if (!newbus) {
			err("out of system memory.\n");
		if (!newbus)
			return -ENOMEM;
		}

		newbus->busno = curr->bus_num;
	} else {
		newbus = *new_bus;
@@ -123,7 +119,6 @@ static int __init alloc_bus_range(struct bus_node **new_bus, struct range_node *
	if (!newrange) {
		if (first_bus)
			kfree(newbus);
		err("out of system memory\n");
		return -ENOMEM;
	}
	newrange->start = curr->start_addr;
@@ -1707,10 +1702,9 @@ static int __init once_over(void)
				bus_cur->firstPFMemFromMem = pfmem_cur;

				mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
				if (!mem) {
					err("out of system memory\n");
				if (!mem)
					return -ENOMEM;
				}

				mem->type = MEM;
				mem->busno = pfmem_cur->busno;
				mem->devfunc = pfmem_cur->devfunc;
@@ -1989,10 +1983,9 @@ static int __init update_bridge_ranges(struct bus_node **bus)

						if ((start_address) && (start_address <= end_address)) {
							range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
							if (!range) {
								err("out of system memory\n");
							if (!range)
								return -ENOMEM;
							}

							range->start = start_address;
							range->end = end_address + 0xfff;

@@ -2016,7 +2009,6 @@ static int __init update_bridge_ranges(struct bus_node **bus)
								io = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
								if (!io) {
									kfree(range);
									err("out of system memory\n");
									return -ENOMEM;
								}
								io->type = IO;
@@ -2038,10 +2030,9 @@ static int __init update_bridge_ranges(struct bus_node **bus)
						if ((start_address) && (start_address <= end_address)) {

							range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
							if (!range) {
								err("out of system memory\n");
							if (!range)
								return -ENOMEM;
							}

							range->start = start_address;
							range->end = end_address + 0xfffff;

@@ -2066,7 +2057,6 @@ static int __init update_bridge_ranges(struct bus_node **bus)
								mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
								if (!mem) {
									kfree(range);
									err("out of system memory\n");
									return -ENOMEM;
								}
								mem->type = MEM;
@@ -2092,10 +2082,9 @@ static int __init update_bridge_ranges(struct bus_node **bus)
						if ((start_address) && (start_address <= end_address)) {

							range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
							if (!range) {
								err("out of system memory\n");
							if (!range)
								return -ENOMEM;
							}

							range->start = start_address;
							range->end = end_address + 0xfffff;

@@ -2119,7 +2108,6 @@ static int __init update_bridge_ranges(struct bus_node **bus)
								pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
								if (!pfmem) {
									kfree(range);
									err("out of system memory\n");
									return -ENOMEM;
								}
								pfmem->type = PFMEM;
Loading