Skip to content

Commit c7abb23

Browse files
elfringbjorn-helgaas
authored andcommitted
PCI: Remove unnecessary messages for memory allocation failures
Per ebfdc40 ("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: Markus Elfring <[email protected]> [bhelgaas: changelog, squash patches, make similar changes to acpiphp, cpqphp, ibmphp, keep warning when dropping hotplug event] Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent fdabc3f commit c7abb23

File tree

9 files changed

+42
-91
lines changed

9 files changed

+42
-91
lines changed

drivers/pci/hotplug/acpiphp_glue.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,10 +811,8 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
811811

812812
handle = adev->handle;
813813
bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
814-
if (!bridge) {
815-
acpi_handle_err(handle, "No memory for bridge object\n");
814+
if (!bridge)
816815
return;
817-
}
818816

819817
INIT_LIST_HEAD(&bridge->slots);
820818
kref_init(&bridge->ref);

drivers/pci/hotplug/cpqphp_core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,6 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
883883

884884
ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
885885
if (!ctrl) {
886-
err("%s : out of memory\n", __func__);
887886
rc = -ENOMEM;
888887
goto err_disable_device;
889888
}

drivers/pci/hotplug/ibmphp_core.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,8 @@ int ibmphp_update_slot_info(struct slot *slot_cur)
603603
u8 mode;
604604

605605
info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
606-
if (!info) {
607-
err("out of system memory\n");
606+
if (!info)
608607
return -ENOMEM;
609-
}
610608

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

736734
bus = kmalloc(sizeof(*bus), GFP_KERNEL);
737-
if (!bus) {
738-
err("%s - out of memory\n", __func__);
735+
if (!bus)
739736
return 1;
740-
}
737+
741738
dev = kmalloc(sizeof(*dev), GFP_KERNEL);
742739
if (!dev) {
743740
kfree(bus);
744-
err("%s - out of memory\n", __func__);
745741
return 1;
746742
}
747743

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

13071301
ibmphp_pci_bus = kmalloc(sizeof(*ibmphp_pci_bus), GFP_KERNEL);
13081302
if (!ibmphp_pci_bus) {
1309-
err("out of memory\n");
13101303
rc = -ENOMEM;
13111304
goto exit;
13121305
}

drivers/pci/hotplug/ibmphp_pci.c

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno)
167167
goto error;
168168
}
169169
newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
170-
if (!newfunc) {
171-
err("out of system memory\n");
170+
if (!newfunc)
172171
return -ENOMEM;
173-
}
172+
174173
newfunc->busno = cur_func->busno;
175174
newfunc->device = device;
176175
cur_func->next = newfunc;
@@ -205,10 +204,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno)
205204
for (i = 0; i < 32; i++) {
206205
if (func->devices[i]) {
207206
newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
208-
if (!newfunc) {
209-
err("out of system memory\n");
207+
if (!newfunc)
210208
return -ENOMEM;
211-
}
209+
212210
newfunc->busno = sec_number;
213211
newfunc->device = (u8) i;
214212
for (j = 0; j < 4; j++)
@@ -233,10 +231,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno)
233231
}
234232

235233
newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
236-
if (!newfunc) {
237-
err("out of system memory\n");
234+
if (!newfunc)
238235
return -ENOMEM;
239-
}
236+
240237
newfunc->busno = cur_func->busno;
241238
newfunc->device = device;
242239
for (j = 0; j < 4; j++)
@@ -279,10 +276,9 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno)
279276
if (func->devices[i]) {
280277
debug("inside for loop, device is %x\n", i);
281278
newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
282-
if (!newfunc) {
283-
err(" out of system memory\n");
279+
if (!newfunc)
284280
return -ENOMEM;
285-
}
281+
286282
newfunc->busno = sec_number;
287283
newfunc->device = (u8) i;
288284
for (j = 0; j < 4; j++)
@@ -405,10 +401,9 @@ static int configure_device(struct pci_func *func)
405401

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

408-
if (!io[count]) {
409-
err("out of system memory\n");
404+
if (!io[count])
410405
return -ENOMEM;
411-
}
406+
412407
io[count]->type = IO;
413408
io[count]->busno = func->busno;
414409
io[count]->devfunc = PCI_DEVFN(func->device, func->function);
@@ -442,10 +437,9 @@ static int configure_device(struct pci_func *func)
442437
debug("len[count] in PFMEM %x, count %d\n", len[count], count);
443438

444439
pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
445-
if (!pfmem[count]) {
446-
err("out of system memory\n");
440+
if (!pfmem[count])
447441
return -ENOMEM;
448-
}
442+
449443
pfmem[count]->type = PFMEM;
450444
pfmem[count]->busno = func->busno;
451445
pfmem[count]->devfunc = PCI_DEVFN(func->device,
@@ -458,7 +452,6 @@ static int configure_device(struct pci_func *func)
458452
} else {
459453
mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
460454
if (!mem_tmp) {
461-
err("out of system memory\n");
462455
kfree(pfmem[count]);
463456
return -ENOMEM;
464457
}
@@ -508,10 +501,9 @@ static int configure_device(struct pci_func *func)
508501
debug("len[count] in Mem %x, count %d\n", len[count], count);
509502

510503
mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
511-
if (!mem[count]) {
512-
err("out of system memory\n");
504+
if (!mem[count])
513505
return -ENOMEM;
514-
}
506+
515507
mem[count]->type = MEM;
516508
mem[count]->busno = func->busno;
517509
mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -674,7 +666,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
674666
bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
675667

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

707698
bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
708699
if (!bus_pfmem[count]) {
709-
err("out of system memory\n");
710700
retval = -ENOMEM;
711701
goto error;
712702
}
@@ -722,7 +712,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
722712
} else {
723713
mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
724714
if (!mem_tmp) {
725-
err("out of system memory\n");
726715
retval = -ENOMEM;
727716
goto error;
728717
}
@@ -763,7 +752,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
763752

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

836824
if (!io) {
837-
err("out of system memory\n");
838825
retval = -ENOMEM;
839826
goto error;
840827
}
@@ -856,7 +843,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
856843
debug("it wants %x memory behind the bridge\n", amount_needed->mem);
857844
mem = kzalloc(sizeof(*mem), GFP_KERNEL);
858845
if (!mem) {
859-
err("out of system memory\n");
860846
retval = -ENOMEM;
861847
goto error;
862848
}
@@ -878,7 +864,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
878864
debug("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem);
879865
pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL);
880866
if (!pfmem) {
881-
err("out of system memory\n");
882867
retval = -ENOMEM;
883868
goto error;
884869
}
@@ -893,7 +878,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
893878
} else {
894879
mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
895880
if (!mem_tmp) {
896-
err("out of system memory\n");
897881
retval = -ENOMEM;
898882
goto error;
899883
}
@@ -924,7 +908,6 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno)
924908
if (!bus) {
925909
bus = kzalloc(sizeof(*bus), GFP_KERNEL);
926910
if (!bus) {
927-
err("out of system memory\n");
928911
retval = -ENOMEM;
929912
goto error;
930913
}
@@ -1652,10 +1635,9 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re
16521635
}
16531636
if (io) {
16541637
io_range = kzalloc(sizeof(*io_range), GFP_KERNEL);
1655-
if (!io_range) {
1656-
err("out of system memory\n");
1638+
if (!io_range)
16571639
return -ENOMEM;
1658-
}
1640+
16591641
io_range->start = io->start;
16601642
io_range->end = io->end;
16611643
io_range->rangeno = 1;
@@ -1664,10 +1646,9 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re
16641646
}
16651647
if (mem) {
16661648
mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL);
1667-
if (!mem_range) {
1668-
err("out of system memory\n");
1649+
if (!mem_range)
16691650
return -ENOMEM;
1670-
}
1651+
16711652
mem_range->start = mem->start;
16721653
mem_range->end = mem->end;
16731654
mem_range->rangeno = 1;
@@ -1676,10 +1657,9 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re
16761657
}
16771658
if (pfmem) {
16781659
pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL);
1679-
if (!pfmem_range) {
1680-
err("out of system memory\n");
1660+
if (!pfmem_range)
16811661
return -ENOMEM;
1682-
}
1662+
16831663
pfmem_range->start = pfmem->start;
16841664
pfmem_range->end = pfmem->end;
16851665
pfmem_range->rangeno = 1;

0 commit comments

Comments
 (0)