diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/pci/hotplug | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.zip | |
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from
scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to
avoid scalar types (which need careful case-by-case checking), and
instead replace kmalloc-family calls that allocate struct or union
object instances:
Single allocations: kmalloc(sizeof(TYPE), ...)
are replaced with: kmalloc_obj(TYPE, ...)
Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...)
are replaced with: kmalloc_objs(TYPE, COUNT, ...)
Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...)
are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...)
(where TYPE may also be *VAR)
The resulting allocations no longer return "void *", instead returning
"TYPE *".
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'drivers/pci/hotplug')
| -rw-r--r-- | drivers/pci/hotplug/acpiphp_core.c | 2 | ||||
| -rw-r--r-- | drivers/pci/hotplug/acpiphp_glue.c | 8 | ||||
| -rw-r--r-- | drivers/pci/hotplug/acpiphp_ibm.c | 2 | ||||
| -rw-r--r-- | drivers/pci/hotplug/cpci_hotplug_core.c | 2 | ||||
| -rw-r--r-- | drivers/pci/hotplug/cpqphp_core.c | 4 | ||||
| -rw-r--r-- | drivers/pci/hotplug/cpqphp_ctrl.c | 24 | ||||
| -rw-r--r-- | drivers/pci/hotplug/cpqphp_nvram.c | 9 | ||||
| -rw-r--r-- | drivers/pci/hotplug/cpqphp_pci.c | 45 | ||||
| -rw-r--r-- | drivers/pci/hotplug/cpqphp_sysfs.c | 2 | ||||
| -rw-r--r-- | drivers/pci/hotplug/ibmphp_core.c | 10 | ||||
| -rw-r--r-- | drivers/pci/hotplug/ibmphp_ebda.c | 27 | ||||
| -rw-r--r-- | drivers/pci/hotplug/ibmphp_pci.c | 54 | ||||
| -rw-r--r-- | drivers/pci/hotplug/ibmphp_res.c | 29 | ||||
| -rw-r--r-- | drivers/pci/hotplug/octep_hp.c | 4 | ||||
| -rw-r--r-- | drivers/pci/hotplug/pciehp_core.c | 2 | ||||
| -rw-r--r-- | drivers/pci/hotplug/pciehp_hpc.c | 2 | ||||
| -rw-r--r-- | drivers/pci/hotplug/pnv_php.c | 4 | ||||
| -rw-r--r-- | drivers/pci/hotplug/rpaphp_slot.c | 2 | ||||
| -rw-r--r-- | drivers/pci/hotplug/shpchp_core.c | 4 | ||||
| -rw-r--r-- | drivers/pci/hotplug/shpchp_ctrl.c | 4 |
20 files changed, 132 insertions, 108 deletions
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index 9dad14e80bcf..051af60f999a 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c @@ -260,7 +260,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot, int retval = -ENOMEM; char name[SLOT_NAME_SIZE]; - slot = kzalloc(sizeof(*slot), GFP_KERNEL); + slot = kzalloc_obj(*slot, GFP_KERNEL); if (!slot) goto error; diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 5b1f271c6034..55620e29b457 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -60,7 +60,7 @@ static struct acpiphp_context *acpiphp_init_context(struct acpi_device *adev) { struct acpiphp_context *context; - context = kzalloc(sizeof(*context), GFP_KERNEL); + context = kzalloc_obj(*context, GFP_KERNEL); if (!context) return NULL; @@ -279,7 +279,7 @@ static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data, if (slot->device == device) goto slot_found; - slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); + slot = kzalloc_obj(struct acpiphp_slot, GFP_KERNEL); if (!slot) { acpi_lock_hp_context(); acpiphp_put_context(context); @@ -869,7 +869,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus) return; handle = adev->handle; - bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); + bridge = kzalloc_obj(struct acpiphp_bridge, GFP_KERNEL); if (!bridge) return; @@ -889,7 +889,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus) if (pci_is_root_bus(bridge->pci_bus)) { struct acpiphp_root_context *root_context; - root_context = kzalloc(sizeof(*root_context), GFP_KERNEL); + root_context = kzalloc_obj(*root_context, GFP_KERNEL); if (!root_context) goto err; diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index 18e01cd55a8e..f86e39e9dd68 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c @@ -141,7 +141,7 @@ static union apci_descriptor *ibm_slot_from_id(int id) ibm_slot_done: if (ret) { - ret = kmalloc(sizeof(union apci_descriptor), GFP_KERNEL); + ret = kmalloc_obj(union apci_descriptor, GFP_KERNEL); if (ret) memcpy(ret, des, sizeof(union apci_descriptor)); } diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index dd93e53ea7c2..50793ca10526 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c @@ -189,7 +189,7 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) * with the pci_hotplug subsystem. */ for (i = first; i <= last; ++i) { - slot = kzalloc(sizeof(struct slot), GFP_KERNEL); + slot = kzalloc_obj(struct slot, GFP_KERNEL); if (!slot) { status = -ENOMEM; goto error; diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index 47a3ed16159a..158859352185 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c @@ -593,7 +593,7 @@ static int ctrl_slot_setup(struct controller *ctrl, slot_number = ctrl->first_slot; while (number_of_slots) { - slot = kzalloc(sizeof(*slot), GFP_KERNEL); + slot = kzalloc_obj(*slot, GFP_KERNEL); if (!slot) { result = -ENOMEM; goto error; @@ -822,7 +822,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_disable_device; } - ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL); + ctrl = kzalloc_obj(struct controller, GFP_KERNEL); if (!ctrl) { rc = -ENOMEM; goto err_disable_device; diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index 760a5dec0431..2c63bdc61306 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c @@ -428,7 +428,7 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h /* this one isn't an aligned length, so we'll make a new entry * and split it up. */ - split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); + split_node = kmalloc_obj(*split_node, GFP_KERNEL); if (!split_node) return NULL; @@ -553,7 +553,7 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size if ((node->length - (temp_dword - node->base)) < size) continue; - split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); + split_node = kmalloc_obj(*split_node, GFP_KERNEL); if (!split_node) return NULL; @@ -573,7 +573,7 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size /* this one is longer than we need * so we'll make a new entry and split it up */ - split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); + split_node = kmalloc_obj(*split_node, GFP_KERNEL); if (!split_node) return NULL; @@ -650,7 +650,7 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz if ((max->length - (temp_dword - max->base)) < size) continue; - split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); + split_node = kmalloc_obj(*split_node, GFP_KERNEL); if (!split_node) return NULL; @@ -668,7 +668,7 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz /* this one isn't end aligned properly at the top * so we'll make a new entry and split it up */ - split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); + split_node = kmalloc_obj(*split_node, GFP_KERNEL); if (!split_node) return NULL; @@ -747,7 +747,7 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size) if ((node->length - (temp_dword - node->base)) < size) continue; - split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); + split_node = kmalloc_obj(*split_node, GFP_KERNEL); if (!split_node) return NULL; @@ -767,7 +767,7 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size) /* this one is longer than we need * so we'll make a new entry and split it up */ - split_node = kmalloc(sizeof(*split_node), GFP_KERNEL); + split_node = kmalloc_obj(*split_node, GFP_KERNEL); if (!split_node) return NULL; @@ -955,7 +955,7 @@ struct pci_func *cpqhp_slot_create(u8 busnumber) struct pci_func *new_slot; struct pci_func *next; - new_slot = kzalloc(sizeof(*new_slot), GFP_KERNEL); + new_slot = kzalloc_obj(*new_slot, GFP_KERNEL); if (new_slot == NULL) return new_slot; @@ -2435,10 +2435,10 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func /* Make copies of the nodes we are going to pass down so that * if there is a problem,we can just use these to free resources */ - hold_bus_node = kmalloc(sizeof(*hold_bus_node), GFP_KERNEL); - hold_IO_node = kmalloc(sizeof(*hold_IO_node), GFP_KERNEL); - hold_mem_node = kmalloc(sizeof(*hold_mem_node), GFP_KERNEL); - hold_p_mem_node = kmalloc(sizeof(*hold_p_mem_node), GFP_KERNEL); + hold_bus_node = kmalloc_obj(*hold_bus_node, GFP_KERNEL); + hold_IO_node = kmalloc_obj(*hold_IO_node, GFP_KERNEL); + hold_mem_node = kmalloc_obj(*hold_mem_node, GFP_KERNEL); + hold_p_mem_node = kmalloc_obj(*hold_p_mem_node, GFP_KERNEL); if (!hold_bus_node || !hold_IO_node || !hold_mem_node || !hold_p_mem_node) { kfree(hold_bus_node); diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c index 7a65d427ac11..83c97f72ca3b 100644 --- a/drivers/pci/hotplug/cpqphp_nvram.c +++ b/drivers/pci/hotplug/cpqphp_nvram.c @@ -504,7 +504,7 @@ int compaq_nvram_load(void __iomem *rom_start, struct controller *ctrl) return 2; while (nummem--) { - mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + mem_node = kmalloc_obj(struct pci_resource, GFP_KERNEL); if (!mem_node) break; @@ -532,7 +532,8 @@ int compaq_nvram_load(void __iomem *rom_start, struct controller *ctrl) } while (numpmem--) { - p_mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + p_mem_node = kmalloc_obj(struct pci_resource, + GFP_KERNEL); if (!p_mem_node) break; @@ -560,7 +561,7 @@ int compaq_nvram_load(void __iomem *rom_start, struct controller *ctrl) } while (numio--) { - io_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + io_node = kmalloc_obj(struct pci_resource, GFP_KERNEL); if (!io_node) break; @@ -588,7 +589,7 @@ int compaq_nvram_load(void __iomem *rom_start, struct controller *ctrl) } while (numbus--) { - bus_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + bus_node = kmalloc_obj(struct pci_resource, GFP_KERNEL); if (!bus_node) break; diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c index 88929360fe77..03e2391f6786 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c @@ -151,8 +151,8 @@ int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num) struct pci_bus *fakebus; u16 temp_word; - fakedev = kmalloc(sizeof(*fakedev), GFP_KERNEL); - fakebus = kmalloc(sizeof(*fakebus), GFP_KERNEL); + fakedev = kmalloc_obj(*fakedev, GFP_KERNEL); + fakebus = kmalloc_obj(*fakebus, GFP_KERNEL); if (!fakedev || !fakebus) { kfree(fakedev); kfree(fakebus); @@ -721,7 +721,7 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus); pci_bus_read_config_byte(pci_bus, devfn, PCI_SUBORDINATE_BUS, &temp_byte); - bus_node = kmalloc(sizeof(*bus_node), GFP_KERNEL); + bus_node = kmalloc_obj(*bus_node, GFP_KERNEL); if (!bus_node) return -ENOMEM; @@ -736,7 +736,7 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) pci_bus_read_config_byte(pci_bus, devfn, PCI_IO_LIMIT, &b_length); if ((b_base <= b_length) && (save_command & 0x01)) { - io_node = kmalloc(sizeof(*io_node), GFP_KERNEL); + io_node = kmalloc_obj(*io_node, GFP_KERNEL); if (!io_node) return -ENOMEM; @@ -752,7 +752,7 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) pci_bus_read_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, &w_length); if ((w_base <= w_length) && (save_command & 0x02)) { - mem_node = kmalloc(sizeof(*mem_node), GFP_KERNEL); + mem_node = kmalloc_obj(*mem_node, GFP_KERNEL); if (!mem_node) return -ENOMEM; @@ -768,7 +768,8 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) pci_bus_read_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &w_length); if ((w_base <= w_length) && (save_command & 0x02)) { - p_mem_node = kmalloc(sizeof(*p_mem_node), GFP_KERNEL); + p_mem_node = kmalloc_obj(*p_mem_node, + GFP_KERNEL); if (!p_mem_node) return -ENOMEM; @@ -799,8 +800,8 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) temp_register = base & 0xFFFFFFFE; temp_register = (~temp_register) + 1; - io_node = kmalloc(sizeof(*io_node), - GFP_KERNEL); + io_node = kmalloc_obj(*io_node, + GFP_KERNEL); if (!io_node) return -ENOMEM; @@ -817,8 +818,8 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) temp_register = base & 0xFFFFFFF0; temp_register = (~temp_register) + 1; - p_mem_node = kmalloc(sizeof(*p_mem_node), - GFP_KERNEL); + p_mem_node = kmalloc_obj(*p_mem_node, + GFP_KERNEL); if (!p_mem_node) return -ENOMEM; @@ -834,8 +835,8 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) temp_register = base & 0xFFFFFFF0; temp_register = (~temp_register) + 1; - mem_node = kmalloc(sizeof(*mem_node), - GFP_KERNEL); + mem_node = kmalloc_obj(*mem_node, + GFP_KERNEL); if (!mem_node) return -ENOMEM; @@ -871,8 +872,8 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) temp_register = base & 0xFFFFFFFE; temp_register = (~temp_register) + 1; - io_node = kmalloc(sizeof(*io_node), - GFP_KERNEL); + io_node = kmalloc_obj(*io_node, + GFP_KERNEL); if (!io_node) return -ENOMEM; @@ -888,8 +889,8 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) temp_register = base & 0xFFFFFFF0; temp_register = (~temp_register) + 1; - p_mem_node = kmalloc(sizeof(*p_mem_node), - GFP_KERNEL); + p_mem_node = kmalloc_obj(*p_mem_node, + GFP_KERNEL); if (!p_mem_node) return -ENOMEM; @@ -905,8 +906,8 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func) temp_register = base & 0xFFFFFFF0; temp_register = (~temp_register) + 1; - mem_node = kmalloc(sizeof(*mem_node), - GFP_KERNEL); + mem_node = kmalloc_obj(*mem_node, + GFP_KERNEL); if (!mem_node) return -ENOMEM; @@ -1293,7 +1294,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st temp_dword = io_base + io_length; if ((io_base) && (temp_dword < 0x10000)) { - io_node = kmalloc(sizeof(*io_node), GFP_KERNEL); + io_node = kmalloc_obj(*io_node, GFP_KERNEL); if (!io_node) return -ENOMEM; @@ -1315,7 +1316,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st /* If we've got a valid memory base, use it */ temp_dword = mem_base + mem_length; if ((mem_base) && (temp_dword < 0x10000)) { - mem_node = kmalloc(sizeof(*mem_node), GFP_KERNEL); + mem_node = kmalloc_obj(*mem_node, GFP_KERNEL); if (!mem_node) return -ENOMEM; @@ -1340,7 +1341,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st */ temp_dword = pre_mem_base + pre_mem_length; if ((pre_mem_base) && (temp_dword < 0x10000)) { - p_mem_node = kmalloc(sizeof(*p_mem_node), GFP_KERNEL); + p_mem_node = kmalloc_obj(*p_mem_node, GFP_KERNEL); if (!p_mem_node) return -ENOMEM; @@ -1365,7 +1366,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st * populated slots that don't have PCI-PCI bridges */ if (secondary_bus && (secondary_bus != primary_bus)) { - bus_node = kmalloc(sizeof(*bus_node), GFP_KERNEL); + bus_node = kmalloc_obj(*bus_node, GFP_KERNEL); if (!bus_node) return -ENOMEM; diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c index 6143ebf71f21..055fff069ce3 100644 --- a/drivers/pci/hotplug/cpqphp_sysfs.c +++ b/drivers/pci/hotplug/cpqphp_sysfs.c @@ -134,7 +134,7 @@ static int open(struct inode *inode, struct file *file) int retval = -ENOMEM; mutex_lock(&cpqphp_mutex); - dbg = kmalloc(sizeof(*dbg), GFP_KERNEL); + dbg = kmalloc_obj(*dbg, GFP_KERNEL); if (!dbg) goto exit; dbg->data = kmalloc(MAX_OUTPUT, GFP_KERNEL); diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index 197997e264a2..af4e8b032093 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c @@ -624,11 +624,11 @@ static u8 bus_structure_fixup(u8 busno) if (pci_find_bus(0, busno) || !(ibmphp_find_same_bus_num(busno))) return 1; - bus = kmalloc(sizeof(*bus), GFP_KERNEL); + bus = kmalloc_obj(*bus, GFP_KERNEL); if (!bus) return 1; - dev = kmalloc(sizeof(*dev), GFP_KERNEL); + dev = kmalloc_obj(*dev, GFP_KERNEL); if (!dev) { kfree(bus); return 1; @@ -986,7 +986,7 @@ static int enable_slot(struct hotplug_slot *hs) goto error_power; } - slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); + slot_cur->func = kzalloc_obj(struct pci_func, GFP_KERNEL); if (!slot_cur->func) { /* do update_slot_info here? */ rc = -ENOMEM; @@ -1093,7 +1093,7 @@ int ibmphp_do_disable_slot(struct slot *slot_cur) if (slot_cur->func == NULL) { /* We need this for functions that were there on bootup */ - slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); + slot_cur->func = kzalloc_obj(struct pci_func, GFP_KERNEL); if (!slot_cur->func) { rc = -ENOMEM; goto error; @@ -1187,7 +1187,7 @@ static int __init ibmphp_init(void) info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); - ibmphp_pci_bus = kmalloc(sizeof(*ibmphp_pci_bus), GFP_KERNEL); + ibmphp_pci_bus = kmalloc_obj(*ibmphp_pci_bus, GFP_KERNEL); if (!ibmphp_pci_bus) { rc = -ENOMEM; goto exit; diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c index 7fb75401ad8a..bfd9f11c2d39 100644 --- a/drivers/pci/hotplug/ibmphp_ebda.c +++ b/drivers/pci/hotplug/ibmphp_ebda.c @@ -57,7 +57,7 @@ static int ebda_rio_table(void); static struct ebda_hpc_list * __init alloc_ebda_hpc_list(void) { - return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL); + return kzalloc_obj(struct ebda_hpc_list, GFP_KERNEL); } static struct controller *alloc_ebda_hpc(u32 slot_count, u32 bus_count) @@ -66,16 +66,16 @@ static struct controller *alloc_ebda_hpc(u32 slot_count, u32 bus_count) struct ebda_hpc_slot *slots; struct ebda_hpc_bus *buses; - controller = kzalloc(sizeof(struct controller), GFP_KERNEL); + controller = kzalloc_obj(struct controller, GFP_KERNEL); if (!controller) goto error; - slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL); + slots = kzalloc_objs(struct ebda_hpc_slot, slot_count, GFP_KERNEL); if (!slots) goto error_contr; controller->slots = slots; - buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL); + buses = kzalloc_objs(struct ebda_hpc_bus, bus_count, GFP_KERNEL); if (!buses) goto error_slots; controller->buses = buses; @@ -98,12 +98,12 @@ static void free_ebda_hpc(struct controller *controller) static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list(void) { - return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL); + return kzalloc_obj(struct ebda_rsrc_list, GFP_KERNEL); } static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc(void) { - return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL); + return kzalloc_obj(struct ebda_pci_rsrc, GFP_KERNEL); } static void __init print_bus_info(void) @@ -352,7 +352,8 @@ int __init ibmphp_access_ebda(void) debug("now enter io table ---\n"); debug("rio blk id: %x\n", blk_id); - rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); + rio_table_ptr = kzalloc_obj(struct rio_table_hdr, + GFP_KERNEL); if (!rio_table_ptr) { rc = -ENOMEM; goto out; @@ -408,7 +409,7 @@ static int __init ebda_rio_table(void) // we do concern about rio details for (i = 0; i < rio_table_ptr->riodev_count; i++) { - rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL); + rio_detail_ptr = kzalloc_obj(struct rio_detail, GFP_KERNEL); if (!rio_detail_ptr) return -ENOMEM; rio_detail_ptr->rio_node_id = readb(io_mem + offset); @@ -461,7 +462,7 @@ static int __init combine_wpg_for_chassis(void) list_for_each_entry(rio_detail_ptr, &rio_vg_head, rio_detail_list) { opt_rio_ptr = search_opt_vg(rio_detail_ptr->chassis_num); if (!opt_rio_ptr) { - opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); + opt_rio_ptr = kzalloc_obj(struct opt_rio, GFP_KERNEL); if (!opt_rio_ptr) return -ENOMEM; opt_rio_ptr->rio_type = rio_detail_ptr->rio_type; @@ -499,7 +500,8 @@ static int combine_wpg_for_expansion(void) list_for_each_entry(rio_detail_ptr, &rio_lo_head, rio_detail_list) { opt_rio_lo_ptr = search_opt_lo(rio_detail_ptr->chassis_num); if (!opt_rio_lo_ptr) { - opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); + opt_rio_lo_ptr = kzalloc_obj(struct opt_rio_lo, + GFP_KERNEL); if (!opt_rio_lo_ptr) return -ENOMEM; opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type; @@ -738,7 +740,8 @@ static int __init ebda_rsrc_controller(void) bus_info_ptr2 = ibmphp_find_same_bus_num(slot_ptr->slot_bus_num); if (!bus_info_ptr2) { - bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL); + bus_info_ptr1 = kzalloc_obj(struct bus_info, + GFP_KERNEL); if (!bus_info_ptr1) { rc = -ENOMEM; goto error_no_slot; @@ -840,7 +843,7 @@ static int __init ebda_rsrc_controller(void) // register slots with hpc core as well as create linked list of ibm slot for (index = 0; index < hpc_ptr->slot_count; index++) { - tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL); + tmp_slot = kzalloc_obj(*tmp_slot, GFP_KERNEL); if (!tmp_slot) { rc = -ENOMEM; goto error_no_slot; diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c index eeb412cbd9fe..f1ec9ada9faa 100644 --- a/drivers/pci/hotplug/ibmphp_pci.c +++ b/drivers/pci/hotplug/ibmphp_pci.c @@ -152,7 +152,8 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno) cleanup_count = 6; goto error; } - newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); + newfunc = kzalloc_obj(*newfunc, + GFP_KERNEL); if (!newfunc) return -ENOMEM; @@ -189,7 +190,8 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno) flag = 0; for (i = 0; i < 32; i++) { if (func->devices[i]) { - newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); + newfunc = kzalloc_obj(*newfunc, + GFP_KERNEL); if (!newfunc) return -ENOMEM; @@ -216,7 +218,8 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno) } } - newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); + newfunc = kzalloc_obj(*newfunc, + GFP_KERNEL); if (!newfunc) return -ENOMEM; @@ -261,7 +264,8 @@ int ibmphp_configure_card(struct pci_func *func, u8 slotno) for (i = 0; i < 32; i++) { if (func->devices[i]) { debug("inside for loop, device is %x\n", i); - newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); + newfunc = kzalloc_obj(*newfunc, + GFP_KERNEL); if (!newfunc) return -ENOMEM; @@ -384,7 +388,8 @@ static int configure_device(struct pci_func *func) debug("len[count] in IO %x, count %d\n", len[count], count); - io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); + io[count] = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!io[count]) return -ENOMEM; @@ -421,7 +426,8 @@ 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); + pfmem[count] = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!pfmem[count]) return -ENOMEM; @@ -435,7 +441,8 @@ static int configure_device(struct pci_func *func) ibmphp_add_resource(pfmem[count]); func->pfmem[count] = pfmem[count]; } else { - mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); + mem_tmp = kzalloc_obj(*mem_tmp, + GFP_KERNEL); if (!mem_tmp) { kfree(pfmem[count]); return -ENOMEM; @@ -485,7 +492,8 @@ 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); + mem[count] = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!mem[count]) return -ENOMEM; @@ -648,7 +656,8 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) debug("len[count] in IO = %x\n", len[count]); - bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); + bus_io[count] = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!bus_io[count]) { retval = -ENOMEM; @@ -680,7 +689,8 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) debug("len[count] in PFMEM = %x\n", len[count]); - bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); + bus_pfmem[count] = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!bus_pfmem[count]) { retval = -ENOMEM; goto error; @@ -695,7 +705,8 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) ibmphp_add_resource(bus_pfmem[count]); func->pfmem[count] = bus_pfmem[count]; } else { - mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); + mem_tmp = kzalloc_obj(*mem_tmp, + GFP_KERNEL); if (!mem_tmp) { retval = -ENOMEM; goto error; @@ -735,7 +746,8 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) debug("len[count] in Memory is %x\n", len[count]); - bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); + bus_mem[count] = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!bus_mem[count]) { retval = -ENOMEM; goto error; @@ -804,7 +816,7 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) flag_io = 1; } else { debug("it wants %x IO behind the bridge\n", amount_needed->io); - io = kzalloc(sizeof(*io), GFP_KERNEL); + io = kzalloc_obj(*io, GFP_KERNEL); if (!io) { retval = -ENOMEM; @@ -826,7 +838,7 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) flag_mem = 1; } else { debug("it wants %x memory behind the bridge\n", amount_needed->mem); - mem = kzalloc(sizeof(*mem), GFP_KERNEL); + mem = kzalloc_obj(*mem, GFP_KERNEL); if (!mem) { retval = -ENOMEM; goto error; @@ -847,7 +859,7 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) flag_pfmem = 1; } else { debug("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); - pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); + pfmem = kzalloc_obj(*pfmem, GFP_KERNEL); if (!pfmem) { retval = -ENOMEM; goto error; @@ -861,7 +873,7 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) ibmphp_add_resource(pfmem); flag_pfmem = 1; } else { - mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); + mem_tmp = kzalloc_obj(*mem_tmp, GFP_KERNEL); if (!mem_tmp) { retval = -ENOMEM; goto error; @@ -891,7 +903,7 @@ static int configure_bridge(struct pci_func **func_passed, u8 slotno) */ bus = ibmphp_find_res_bus(sec_number); if (!bus) { - bus = kzalloc(sizeof(*bus), GFP_KERNEL); + bus = kzalloc_obj(*bus, GFP_KERNEL); if (!bus) { retval = -ENOMEM; goto error; @@ -1064,7 +1076,7 @@ static struct res_needed *scan_behind_bridge(struct pci_func *func, u8 busno) }; struct res_needed *amount; - amount = kzalloc(sizeof(*amount), GFP_KERNEL); + amount = kzalloc_obj(*amount, GFP_KERNEL); if (amount == NULL) return NULL; @@ -1618,7 +1630,7 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re list_add(&bus->bus_list, &cur_bus->bus_list); } if (io) { - io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); + io_range = kzalloc_obj(*io_range, GFP_KERNEL); if (!io_range) return -ENOMEM; @@ -1629,7 +1641,7 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re bus->rangeIO = io_range; } if (mem) { - mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); + mem_range = kzalloc_obj(*mem_range, GFP_KERNEL); if (!mem_range) return -ENOMEM; @@ -1640,7 +1652,7 @@ static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct re bus->rangeMem = mem_range; } if (pfmem) { - pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); + pfmem_range = kzalloc_obj(*pfmem_range, GFP_KERNEL); if (!pfmem_range) return -ENOMEM; diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c index 4a72ade2cddb..c05a2c05e302 100644 --- a/drivers/pci/hotplug/ibmphp_res.c +++ b/drivers/pci/hotplug/ibmphp_res.c @@ -41,7 +41,7 @@ static struct bus_node * __init alloc_error_bus(struct ebda_pci_rsrc *curr, u8 b return NULL; } - newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); + newbus = kzalloc_obj(struct bus_node, GFP_KERNEL); if (!newbus) return NULL; @@ -62,7 +62,7 @@ static struct resource_node * __init alloc_resources(struct ebda_pci_rsrc *curr) return NULL; } - rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); + rs = kzalloc_obj(struct resource_node, GFP_KERNEL); if (!rs) return NULL; @@ -81,7 +81,7 @@ static int __init alloc_bus_range(struct bus_node **new_bus, struct range_node * u8 num_ranges = 0; if (first_bus) { - newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); + newbus = kzalloc_obj(struct bus_node, GFP_KERNEL); if (!newbus) return -ENOMEM; @@ -101,7 +101,7 @@ static int __init alloc_bus_range(struct bus_node **new_bus, struct range_node * } } - newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL); + newrange = kzalloc_obj(struct range_node, GFP_KERNEL); if (!newrange) { if (first_bus) kfree(newbus); @@ -1687,7 +1687,8 @@ static int __init once_over(void) bus_cur->firstPFMemFromMem = pfmem_cur; - mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); + mem = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!mem) return -ENOMEM; @@ -1969,7 +1970,8 @@ static int __init update_bridge_ranges(struct bus_node **bus) end_address |= (upper_io_end << 16); if ((start_address) && (start_address <= end_address)) { - range = kzalloc(sizeof(struct range_node), GFP_KERNEL); + range = kzalloc_obj(struct range_node, + GFP_KERNEL); if (!range) return -ENOMEM; @@ -1993,7 +1995,8 @@ static int __init update_bridge_ranges(struct bus_node **bus) fix_resources(bus_sec); if (ibmphp_find_resource(bus_cur, start_address, &io, IO)) { - io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); + io = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!io) { kfree(range); return -ENOMEM; @@ -2016,7 +2019,8 @@ 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); + range = kzalloc_obj(struct range_node, + GFP_KERNEL); if (!range) return -ENOMEM; @@ -2041,7 +2045,8 @@ static int __init update_bridge_ranges(struct bus_node **bus) fix_resources(bus_sec); if (ibmphp_find_resource(bus_cur, start_address, &mem, MEM)) { - mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); + mem = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!mem) { kfree(range); return -ENOMEM; @@ -2068,7 +2073,8 @@ 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); + range = kzalloc_obj(struct range_node, + GFP_KERNEL); if (!range) return -ENOMEM; @@ -2092,7 +2098,8 @@ static int __init update_bridge_ranges(struct bus_node **bus) fix_resources(bus_sec); if (ibmphp_find_resource(bus_cur, start_address, &pfmem, PFMEM)) { - pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); + pfmem = kzalloc_obj(struct resource_node, + GFP_KERNEL); if (!pfmem) { kfree(range); return -ENOMEM; diff --git a/drivers/pci/hotplug/octep_hp.c b/drivers/pci/hotplug/octep_hp.c index 2bce7296c050..109513822589 100644 --- a/drivers/pci/hotplug/octep_hp.c +++ b/drivers/pci/hotplug/octep_hp.c @@ -136,7 +136,7 @@ octep_hp_register_slot(struct octep_hp_controller *hp_ctrl, struct octep_hp_slot *hp_slot; int ret; - hp_slot = kzalloc(sizeof(*hp_slot), GFP_KERNEL); + hp_slot = kzalloc_obj(*hp_slot, GFP_KERNEL); if (!hp_slot) return ERR_PTR(-ENOMEM); @@ -271,7 +271,7 @@ static irqreturn_t octep_hp_intr_handler(int irq, void *data) intr_val = readq(hp_ctrl->base + OCTEP_HP_INTR_OFFSET(type)); writeq(intr_val, hp_ctrl->base + OCTEP_HP_INTR_OFFSET(type)); - hp_cmd = kzalloc(sizeof(*hp_cmd), GFP_ATOMIC); + hp_cmd = kzalloc_obj(*hp_cmd, GFP_ATOMIC); if (!hp_cmd) return IRQ_HANDLED; diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index f59baa912970..b344ccb3cbc1 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -55,7 +55,7 @@ static int init_slot(struct controller *ctrl) int retval; /* Setup hotplug slot ops */ - ops = kzalloc(sizeof(*ops), GFP_KERNEL); + ops = kzalloc_obj(*ops, GFP_KERNEL); if (!ops) return -ENOMEM; diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index ad5f28f6a8b1..33396ad0331c 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -1011,7 +1011,7 @@ struct controller *pcie_init(struct pcie_device *dev) struct pci_dev *pdev = dev->port; struct pci_bus *subordinate = pdev->subordinate; - ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); + ctrl = kzalloc_obj(*ctrl, GFP_KERNEL); if (!ctrl) return NULL; diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c index 35f1758126c6..4364f068fb72 100644 --- a/drivers/pci/hotplug/pnv_php.c +++ b/drivers/pci/hotplug/pnv_php.c @@ -791,7 +791,7 @@ static struct pnv_php_slot *pnv_php_alloc_slot(struct device_node *dn) if (!bus) return NULL; - php_slot = kzalloc(sizeof(*php_slot), GFP_KERNEL); + php_slot = kzalloc_obj(*php_slot, GFP_KERNEL); if (!php_slot) return NULL; @@ -1028,7 +1028,7 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data) * The PE is left in frozen state if the event is missed. It's * fine as the PCI devices (PE) aren't functional any more. */ - event = kzalloc(sizeof(*event), GFP_ATOMIC); + event = kzalloc_obj(*event, GFP_ATOMIC); if (!event) { SLOT_WARN(php_slot, "PCI slot [%s] missed hotplug event 0x%04x\n", diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index 779eab12e981..730a3d6c12ba 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c @@ -32,7 +32,7 @@ struct slot *alloc_slot_struct(struct device_node *dn, { struct slot *slot; - slot = kzalloc(sizeof(struct slot), GFP_KERNEL); + slot = kzalloc_obj(struct slot, GFP_KERNEL); if (!slot) goto error_nomem; slot->name = kstrdup(drc_name, GFP_KERNEL); diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 56308515ecba..13687b666f7a 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c @@ -66,7 +66,7 @@ static int init_slots(struct controller *ctrl) int i; for (i = 0; i < ctrl->num_slots; i++) { - slot = kzalloc(sizeof(*slot), GFP_KERNEL); + slot = kzalloc_obj(*slot, GFP_KERNEL); if (!slot) { retval = -ENOMEM; goto error; @@ -259,7 +259,7 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (acpi_get_hp_hw_control_from_firmware(pdev)) return -ENODEV; - ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); + ctrl = kzalloc_obj(*ctrl, GFP_KERNEL); if (!ctrl) goto err_out_none; diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c index e6c6f23bae27..20526c1fa441 100644 --- a/drivers/pci/hotplug/shpchp_ctrl.c +++ b/drivers/pci/hotplug/shpchp_ctrl.c @@ -29,7 +29,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type) { struct event_info *info; - info = kmalloc(sizeof(*info), GFP_ATOMIC); + info = kmalloc_obj(*info, GFP_ATOMIC); if (!info) return -ENOMEM; @@ -418,7 +418,7 @@ void shpchp_queue_pushbutton_work(struct work_struct *work) struct slot *p_slot = container_of(work, struct slot, work.work); struct pushbutton_work_info *info; - info = kmalloc(sizeof(*info), GFP_KERNEL); + info = kmalloc_obj(*info, GFP_KERNEL); if (!info) { ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n", __func__); |
