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/firmware | |
| 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/firmware')
36 files changed, 61 insertions, 63 deletions
diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index 50bfe56c755e..fbd9af875a69 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -203,7 +203,7 @@ ffa_device_register(const struct ffa_partition_info *part_info, if (id < 0) return NULL; - ffa_dev = kzalloc(sizeof(*ffa_dev), GFP_KERNEL); + ffa_dev = kzalloc_obj(*ffa_dev, GFP_KERNEL); if (!ffa_dev) { ida_free(&ffa_bus_id, id); return NULL; diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 8144f6a9f0e9..8962212ad218 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -410,7 +410,7 @@ ffa_partition_probe(const uuid_t *uuid, struct ffa_partition_info **buffer) if (count <= 0) return count; - pbuf = kcalloc(count, sizeof(*pbuf), GFP_KERNEL); + pbuf = kzalloc_objs(*pbuf, count, GFP_KERNEL); if (!pbuf) return -ENOMEM; @@ -1376,7 +1376,7 @@ static int __ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, if (notify_id >= FFA_MAX_NOTIFICATIONS) return -EINVAL; - cb_info = kzalloc(sizeof(*cb_info), GFP_KERNEL); + cb_info = kzalloc_obj(*cb_info, GFP_KERNEL); if (!cb_info) return -ENOMEM; @@ -1647,7 +1647,7 @@ static int ffa_xa_add_partition_info(struct ffa_device *dev) } } - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc_obj(*info, GFP_KERNEL); if (!info) return ret; @@ -1655,7 +1655,7 @@ static int ffa_xa_add_partition_info(struct ffa_device *dev) info->dev = dev; if (!phead) { - phead = kzalloc(sizeof(*phead), GFP_KERNEL); + phead = kzalloc_obj(*phead, GFP_KERNEL); if (!phead) goto free_out; @@ -2039,7 +2039,7 @@ static int __init ffa_init(void) if (ret) return ret; - drv_info = kzalloc(sizeof(*drv_info), GFP_KERNEL); + drv_info = kzalloc_obj(*drv_info, GFP_KERNEL); if (!drv_info) return -ENOMEM; diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index c7698cfaa4e8..49a168c5ff85 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -90,7 +90,7 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table) * No duplicate found for requested id_table, so let's create a new * requested device entry for this new valid request. */ - rdev = kzalloc(sizeof(*rdev), GFP_KERNEL); + rdev = kzalloc_obj(*rdev, GFP_KERNEL); if (!rdev) { ret = -ENOMEM; goto out; @@ -103,7 +103,7 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table) * there. */ if (!phead) { - phead = kzalloc(sizeof(*phead), GFP_KERNEL); + phead = kzalloc_obj(*phead, GFP_KERNEL); if (!phead) { kfree(rdev); ret = -ENOMEM; @@ -445,7 +445,7 @@ __scmi_device_create(struct device_node *np, struct device *parent, return NULL; } - scmi_dev = kzalloc(sizeof(*scmi_dev), GFP_KERNEL); + scmi_dev = kzalloc_obj(*scmi_dev, GFP_KERNEL); if (!scmi_dev) return NULL; diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c index dee9f238f6fd..d2a6390cbc5c 100644 --- a/drivers/firmware/arm_scmi/notify.c +++ b/drivers/firmware/arm_scmi/notify.c @@ -897,7 +897,7 @@ scmi_allocate_event_handler(struct scmi_notify_instance *ni, u32 evt_key) { struct scmi_event_handler *hndl; - hndl = kzalloc(sizeof(*hndl), GFP_KERNEL); + hndl = kzalloc_obj(*hndl, GFP_KERNEL); if (!hndl) return NULL; hndl->key = evt_key; diff --git a/drivers/firmware/arm_scmi/raw_mode.c b/drivers/firmware/arm_scmi/raw_mode.c index 73db5492ab44..99a4a70cf117 100644 --- a/drivers/firmware/arm_scmi/raw_mode.c +++ b/drivers/firmware/arm_scmi/raw_mode.c @@ -908,7 +908,7 @@ static int scmi_dbg_raw_mode_open(struct inode *inode, struct file *filp) return -ENODEV; raw = inode->i_private; - rd = kzalloc(sizeof(*rd), GFP_KERNEL); + rd = kzalloc_obj(*rd, GFP_KERNEL); if (!rd) return -ENOMEM; diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c index 87c323de17b9..70a1697a1e6b 100644 --- a/drivers/firmware/arm_scpi.c +++ b/drivers/firmware/arm_scpi.c @@ -633,14 +633,14 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain) if (!buf.opp_count) return ERR_PTR(-ENOENT); - info = kmalloc(sizeof(*info), GFP_KERNEL); + info = kmalloc_obj(*info, GFP_KERNEL); if (!info) return ERR_PTR(-ENOMEM); info->count = buf.opp_count; info->latency = le16_to_cpu(buf.latency) * 1000; /* uS to nS */ - info->opps = kcalloc(info->count, sizeof(*opp), GFP_KERNEL); + info->opps = kzalloc_objs(*opp, info->count, GFP_KERNEL); if (!info->opps) { kfree(info); return ERR_PTR(-ENOMEM); diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 71e2a9a89f6a..c8d737e754e6 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -205,7 +205,7 @@ static struct sdei_event *sdei_event_create(u32 event_num, lockdep_assert_held(&sdei_events_lock); - event = kzalloc(sizeof(*event), GFP_KERNEL); + event = kzalloc_obj(*event, GFP_KERNEL); if (!event) { err = -ENOMEM; goto fail; @@ -227,7 +227,7 @@ static struct sdei_event *sdei_event_create(u32 event_num, event->type = result; if (event->type == SDEI_EVENT_TYPE_SHARED) { - reg = kzalloc(sizeof(*reg), GFP_KERNEL); + reg = kzalloc_obj(*reg, GFP_KERNEL); if (!reg) { err = -ENOMEM; goto fail; diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c index 9fdb50f3fec6..148d31eea977 100644 --- a/drivers/firmware/cirrus/cs_dsp.c +++ b/drivers/firmware/cirrus/cs_dsp.c @@ -1059,7 +1059,7 @@ static int cs_dsp_create_control(struct cs_dsp *dsp, } } - ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); + ctl = kzalloc_obj(*ctl, GFP_KERNEL); if (!ctl) return -ENOMEM; @@ -1781,7 +1781,7 @@ static struct cs_dsp_alg_region *cs_dsp_create_region(struct cs_dsp *dsp, { struct cs_dsp_alg_region_list_item *item; - item = kzalloc(sizeof(*item), GFP_KERNEL); + item = kzalloc_obj(*item, GFP_KERNEL); if (!item) return ERR_PTR(-ENOMEM); diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c index 08e1552c2f74..dddddfbc479d 100644 --- a/drivers/firmware/dmi-id.c +++ b/drivers/firmware/dmi-id.c @@ -237,7 +237,7 @@ static int __init dmi_id_init(void) if (ret) return ret; - dmi_dev = kzalloc(sizeof(*dmi_dev), GFP_KERNEL); + dmi_dev = kzalloc_obj(*dmi_dev, GFP_KERNEL); if (!dmi_dev) { ret = -ENOMEM; goto fail_class_unregister; diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c index 9cc963b2edc0..4424ad075aff 100644 --- a/drivers/firmware/dmi-sysfs.c +++ b/drivers/firmware/dmi-sysfs.c @@ -451,7 +451,7 @@ static int dmi_system_event_log(struct dmi_sysfs_entry *entry) { int ret; - entry->child = kzalloc(sizeof(*entry->child), GFP_KERNEL); + entry->child = kzalloc_obj(*entry->child, GFP_KERNEL); if (!entry->child) return -ENOMEM; ret = kobject_init_and_add(entry->child, @@ -586,7 +586,7 @@ static void __init dmi_sysfs_register_handle(const struct dmi_header *dh, return; /* Allocate and register a new entry into the entries set */ - entry = kzalloc(sizeof(*entry), GFP_KERNEL); + entry = kzalloc_obj(*entry, GFP_KERNEL); if (!entry) { *ret = -ENOMEM; return; diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index 55dec4eb2c00..631fbd3ea60c 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c @@ -740,7 +740,7 @@ edd_init(void) return -ENOMEM; for (i = 0; i < edd_num_devices(); i++) { - edev = kzalloc(sizeof (*edev), GFP_KERNEL); + edev = kzalloc_obj(*edev, GFP_KERNEL); if (!edev) { rc = -ENOMEM; goto out; diff --git a/drivers/firmware/efi/apple-properties.c b/drivers/firmware/efi/apple-properties.c index ea84108035eb..c458852cea76 100644 --- a/drivers/firmware/efi/apple-properties.c +++ b/drivers/firmware/efi/apple-properties.c @@ -146,8 +146,8 @@ static int __init unmarshal_devices(struct properties_header *properties) goto skip_device; } - entry = kcalloc(dev_header->prop_count + 1, sizeof(*entry), - GFP_KERNEL); + entry = kzalloc_objs(*entry, dev_header->prop_count + 1, + GFP_KERNEL); if (!entry) { dev_err(dev, "cannot allocate properties\n"); goto skip_device; diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 53a5336cde5a..35b69e629d6d 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -113,7 +113,7 @@ static int __init arm_enable_runtime_services(void) if (!(md->attribute & EFI_MEMORY_SP)) continue; - res = kzalloc(sizeof(*res), GFP_KERNEL); + res = kzalloc_obj(*res, GFP_KERNEL); if (WARN_ON(!res)) break; diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 0c17bdd388e1..609637f88acc 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -282,7 +282,7 @@ static int efi_capsule_open(struct inode *inode, struct file *file) { struct capsule_info *cap_info; - cap_info = kzalloc(sizeof(*cap_info), GFP_KERNEL); + cap_info = kzalloc_obj(*cap_info, GFP_KERNEL); if (!cap_info) return -ENOMEM; @@ -292,7 +292,7 @@ static int efi_capsule_open(struct inode *inode, struct file *file) return -ENOMEM; } - cap_info->phys = kzalloc(sizeof(phys_addr_t), GFP_KERNEL); + cap_info->phys = kzalloc_obj(phys_addr_t, GFP_KERNEL); if (!cap_info->phys) { kfree(cap_info->pages); kfree(cap_info); diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c index 768430293669..dbbff6ade4e3 100644 --- a/drivers/firmware/efi/capsule.c +++ b/drivers/firmware/efi/capsule.c @@ -230,7 +230,7 @@ int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages) count = DIV_ROUND_UP(imagesize, PAGE_SIZE); sg_count = sg_pages_num(count); - sg_pages = kcalloc(sg_count, sizeof(*sg_pages), GFP_KERNEL); + sg_pages = kzalloc_objs(*sg_pages, sg_count, GFP_KERNEL); if (!sg_pages) return -ENOMEM; diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 56e9d73412fa..b2fb92a4bbd1 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -1079,7 +1079,7 @@ static int efi_mem_reserve_iomem(phys_addr_t addr, u64 size) struct resource *res, *parent; int ret; - res = kzalloc(sizeof(struct resource), GFP_ATOMIC); + res = kzalloc_obj(struct resource, GFP_ATOMIC); if (!res) return -ENOMEM; diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c index 0a7c764dcc61..99268c14e01e 100644 --- a/drivers/firmware/efi/efibc.c +++ b/drivers/firmware/efi/efibc.c @@ -47,7 +47,7 @@ static int efibc_reboot_notifier_call(struct notifier_block *notifier, if (ret || !data) return NOTIFY_DONE; - wdata = kmalloc_array(MAX_DATA_LEN, sizeof(efi_char16_t), GFP_KERNEL); + wdata = kmalloc_objs(efi_char16_t, MAX_DATA_LEN, GFP_KERNEL); if (!wdata) return NOTIFY_DONE; diff --git a/drivers/firmware/efi/embedded-firmware.c b/drivers/firmware/efi/embedded-firmware.c index b49a09d7e665..e750ef2b57e8 100644 --- a/drivers/firmware/efi/embedded-firmware.c +++ b/drivers/firmware/efi/embedded-firmware.c @@ -64,7 +64,7 @@ static int __init efi_check_md_for_embedded_firmware( pr_info("Found EFI embedded fw '%s'\n", desc->name); - fw = kmalloc(sizeof(*fw), GFP_KERNEL); + fw = kmalloc_obj(*fw, GFP_KERNEL); if (!fw) { memunmap(map); return -ENOMEM; diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c index 4bb7b0584bc9..74f38a2df8d7 100644 --- a/drivers/firmware/efi/esrt.c +++ b/drivers/firmware/efi/esrt.c @@ -164,7 +164,7 @@ static int esre_create_sysfs_entry(void *esre, int entry_num) { struct esre_entry *entry; - entry = kzalloc(sizeof(*entry), GFP_KERNEL); + entry = kzalloc_obj(*entry, GFP_KERNEL); if (!entry) return -ENOMEM; diff --git a/drivers/firmware/efi/mokvar-table.c b/drivers/firmware/efi/mokvar-table.c index aedbbd627706..78afd0fa2919 100644 --- a/drivers/firmware/efi/mokvar-table.c +++ b/drivers/firmware/efi/mokvar-table.c @@ -329,7 +329,7 @@ static int __init efi_mokvar_sysfs_init(void) } while (efi_mokvar_entry_next(&mokvar_entry)) { - mokvar_sysfs = kzalloc(sizeof(*mokvar_sysfs), GFP_KERNEL); + mokvar_sysfs = kzalloc_obj(*mokvar_sysfs, GFP_KERNEL); if (!mokvar_sysfs) { err = -ENOMEM; break; diff --git a/drivers/firmware/efi/riscv-runtime.c b/drivers/firmware/efi/riscv-runtime.c index 66f584a228d0..ee799399da62 100644 --- a/drivers/firmware/efi/riscv-runtime.c +++ b/drivers/firmware/efi/riscv-runtime.c @@ -83,7 +83,7 @@ static int __init riscv_enable_runtime_services(void) if (!(md->attribute & EFI_MEMORY_SP)) continue; - res = kzalloc(sizeof(*res), GFP_KERNEL); + res = kzalloc_obj(*res, GFP_KERNEL); if (WARN_ON(!res)) break; diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c index 77b5f7ac3e20..0e3b00a572b2 100644 --- a/drivers/firmware/efi/test/efi_test.c +++ b/drivers/firmware/efi/test/efi_test.c @@ -614,8 +614,8 @@ static long efi_runtime_query_capsulecaps(unsigned long arg) if (qcaps.capsule_count == ULONG_MAX) return -EINVAL; - capsules = kcalloc(qcaps.capsule_count + 1, - sizeof(efi_capsule_header_t), GFP_KERNEL); + capsules = kzalloc_objs(efi_capsule_header_t, qcaps.capsule_count + 1, + GFP_KERNEL); if (!capsules) return -ENOMEM; diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index 0ceccde5a302..a142ce5c7288 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -153,7 +153,7 @@ static struct gsmi_buf *gsmi_buf_alloc(void) { struct gsmi_buf *smibuf; - smibuf = kzalloc(sizeof(*smibuf), GFP_KERNEL); + smibuf = kzalloc_obj(*smibuf, GFP_KERNEL); if (!smibuf) { printk(KERN_ERR "gsmi: out of memory\n"); return NULL; diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c index 339a3f74b247..721dfa756c45 100644 --- a/drivers/firmware/google/vpd.c +++ b/drivers/firmware/google/vpd.c @@ -107,7 +107,7 @@ static int vpd_section_attrib_add(const u8 *key, u32 key_len, if (vpd_section_check_key_name(key, key_len) != VPD_OK) return VPD_OK; - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc_obj(*info, GFP_KERNEL); if (!info) return -ENOMEM; diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c index 371f24569b3b..1af5a9ef4474 100644 --- a/drivers/firmware/iscsi_ibft.c +++ b/drivers/firmware/iscsi_ibft.c @@ -634,7 +634,7 @@ static int __init ibft_create_kobject(struct acpi_table_ibft *header, struct pci_dev *pci_dev; int rc = 0; - ibft_kobj = kzalloc(sizeof(*ibft_kobj), GFP_KERNEL); + ibft_kobj = kzalloc_obj(*ibft_kobj, GFP_KERNEL); if (!ibft_kobj) return -ENOMEM; @@ -773,7 +773,7 @@ static int __init ibft_register_kobjects(struct acpi_table_ibft *header) if (rc) return rc; - ibft_kobj = kzalloc(sizeof(*ibft_kobj), GFP_KERNEL); + ibft_kobj = kzalloc_obj(*ibft_kobj, GFP_KERNEL); if (!ibft_kobj) return -ENOMEM; diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c index 55b9cfad8a04..5862fbae9b78 100644 --- a/drivers/firmware/memmap.c +++ b/drivers/firmware/memmap.c @@ -289,7 +289,7 @@ int __meminit firmware_map_add_hotplug(u64 start, u64 end, const char *type) entry = firmware_map_find_entry_bootmem(start, end - 1, type); if (!entry) { - entry = kzalloc(sizeof(struct firmware_map_entry), GFP_ATOMIC); + entry = kzalloc_obj(struct firmware_map_entry, GFP_ATOMIC); if (!entry) return -ENOMEM; } else { diff --git a/drivers/firmware/microchip/mpfs-auto-update.c b/drivers/firmware/microchip/mpfs-auto-update.c index e194f7acb2a9..5fa85af40c33 100644 --- a/drivers/firmware/microchip/mpfs-auto-update.c +++ b/drivers/firmware/microchip/mpfs-auto-update.c @@ -162,9 +162,9 @@ static int mpfs_auto_update_verify_image(struct fw_upload *fw_uploader) u32 *response_msg __free(kfree) = kzalloc(AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof(*response_msg), GFP_KERNEL); struct mpfs_mss_response *response __free(kfree) = - kzalloc(sizeof(struct mpfs_mss_response), GFP_KERNEL); + kzalloc_obj(struct mpfs_mss_response, GFP_KERNEL); struct mpfs_mss_msg *message __free(kfree) = - kzalloc(sizeof(struct mpfs_mss_msg), GFP_KERNEL); + kzalloc_obj(struct mpfs_mss_msg, GFP_KERNEL); int ret; if (!response_msg || !response || !message) @@ -364,9 +364,9 @@ static int mpfs_auto_update_available(struct mpfs_auto_update_priv *priv) u32 *response_msg __free(kfree) = kzalloc(AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof(*response_msg), GFP_KERNEL); struct mpfs_mss_response *response __free(kfree) = - kzalloc(sizeof(struct mpfs_mss_response), GFP_KERNEL); + kzalloc_obj(struct mpfs_mss_response, GFP_KERNEL); struct mpfs_mss_msg *message __free(kfree) = - kzalloc(sizeof(struct mpfs_mss_msg), GFP_KERNEL); + kzalloc_obj(struct mpfs_mss_msg, GFP_KERNEL); int ret; if (!response_msg || !response || !message) diff --git a/drivers/firmware/psci/psci_checker.c b/drivers/firmware/psci/psci_checker.c index df02a4ec3398..2aaf3519cdfb 100644 --- a/drivers/firmware/psci/psci_checker.c +++ b/drivers/firmware/psci/psci_checker.c @@ -155,8 +155,7 @@ static int alloc_init_cpu_groups(cpumask_var_t **pcpu_groups) if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) return -ENOMEM; - cpu_groups = kcalloc(nb_available_cpus, sizeof(*cpu_groups), - GFP_KERNEL); + cpu_groups = kzalloc_objs(*cpu_groups, nb_available_cpus, GFP_KERNEL); if (!cpu_groups) { free_cpumask_var(tmp); return -ENOMEM; @@ -370,8 +369,7 @@ static int suspend_tests(void) struct task_struct **threads; int nb_threads = 0; - threads = kmalloc_array(nb_available_cpus, sizeof(*threads), - GFP_KERNEL); + threads = kmalloc_objs(*threads, nb_available_cpus, GFP_KERNEL); if (!threads) return -ENOMEM; diff --git a/drivers/firmware/qcom/qcom_qseecom.c b/drivers/firmware/qcom/qcom_qseecom.c index 731e6d5719f9..7eed43fc8174 100644 --- a/drivers/firmware/qcom/qcom_qseecom.c +++ b/drivers/firmware/qcom/qcom_qseecom.c @@ -50,7 +50,7 @@ static int qseecom_client_register(struct platform_device *qseecom_dev, dev_info(&qseecom_dev->dev, "setting up client for %s\n", desc->app_name); /* Allocate and set-up the client device */ - client = kzalloc(sizeof(*client), GFP_KERNEL); + client = kzalloc_obj(*client, GFP_KERNEL); if (!client) return -ENOMEM; diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c index 9f232e53115e..74ea67a49cab 100644 --- a/drivers/firmware/qcom/qcom_tzmem.c +++ b/drivers/firmware/qcom/qcom_tzmem.c @@ -262,8 +262,8 @@ qcom_tzmem_pool_new(const struct qcom_tzmem_pool_config *config) return ERR_PTR(-EINVAL); } - struct qcom_tzmem_pool *pool __free(kfree) = kzalloc(sizeof(*pool), - GFP_KERNEL); + struct qcom_tzmem_pool *pool __free(kfree) = kzalloc_obj(*pool, + GFP_KERNEL); if (!pool) return ERR_PTR(-ENOMEM); diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c index 0eebd572f9a5..50224b95d22b 100644 --- a/drivers/firmware/qemu_fw_cfg.c +++ b/drivers/firmware/qemu_fw_cfg.c @@ -94,7 +94,7 @@ static ssize_t fw_cfg_dma_transfer(void *address, u32 length, u32 control) struct fw_cfg_dma_access *d = NULL; ssize_t ret = length; - d = kmalloc(sizeof(*d), GFP_KERNEL); + d = kmalloc_obj(*d, GFP_KERNEL); if (!d) { ret = -ENOMEM; goto end; @@ -325,7 +325,7 @@ static ssize_t fw_cfg_write_vmcoreinfo(const struct fw_cfg_file *f) static struct fw_cfg_vmcoreinfo *data; ssize_t ret; - data = kmalloc(sizeof(struct fw_cfg_vmcoreinfo), GFP_KERNEL); + data = kmalloc_obj(struct fw_cfg_vmcoreinfo, GFP_KERNEL); if (!data) return -ENOMEM; @@ -530,7 +530,7 @@ static int fw_cfg_build_symlink(struct kset *dir, dir = to_kset(ko); } else { /* create new subdirectory kset */ - subdir = kzalloc(sizeof(struct kset), GFP_KERNEL); + subdir = kzalloc_obj(struct kset, GFP_KERNEL); if (!subdir) { ret = -ENOMEM; break; @@ -593,7 +593,7 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f) #endif /* allocate new entry */ - entry = kzalloc(sizeof(*entry), GFP_KERNEL); + entry = kzalloc_obj(*entry, GFP_KERNEL); if (!entry) return -ENOMEM; diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 7ecde6921a0a..3b45bb74d312 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -282,7 +282,7 @@ static int rpi_firmware_probe(struct platform_device *pdev) * Memory will be freed by rpi_firmware_delete() once all users have * released their firmware handles. Don't use devm_kzalloc() here. */ - fw = kzalloc(sizeof(*fw), GFP_KERNEL); + fw = kzalloc_obj(*fw, GFP_KERNEL); if (!fw) return -ENOMEM; diff --git a/drivers/firmware/smccc/soc_id.c b/drivers/firmware/smccc/soc_id.c index c24b3fca1cfe..95f9163058bb 100644 --- a/drivers/firmware/smccc/soc_id.c +++ b/drivers/firmware/smccc/soc_id.c @@ -137,7 +137,7 @@ static int __init smccc_soc_init(void) return -EINVAL; } - soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + soc_dev_attr = kzalloc_obj(*soc_dev_attr, GFP_KERNEL); if (!soc_dev_attr) return -ENOMEM; diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c index dbed404a71fc..aefb28933990 100644 --- a/drivers/firmware/stratix10-svc.c +++ b/drivers/firmware/stratix10-svc.c @@ -535,11 +535,11 @@ static int svc_normal_to_secure_thread(void *data) unsigned long a0, a1, a2, a3, a4, a5, a6, a7; int ret_fifo = 0; - pdata = kmalloc(sizeof(*pdata), GFP_KERNEL); + pdata = kmalloc_obj(*pdata, GFP_KERNEL); if (!pdata) return -ENOMEM; - cbdata = kmalloc(sizeof(*cbdata), GFP_KERNEL); + cbdata = kmalloc_obj(*cbdata, GFP_KERNEL); if (!cbdata) { kfree(pdata); return -ENOMEM; @@ -1119,7 +1119,7 @@ int stratix10_svc_add_async_client(struct stratix10_svc_chan *chan, return 0; } - achan = kzalloc(sizeof(*achan), GFP_KERNEL); + achan = kzalloc_obj(*achan, GFP_KERNEL); if (!achan) return -ENOMEM; @@ -1692,7 +1692,7 @@ int stratix10_svc_send(struct stratix10_svc_chan *chan, void *msg) int ret = 0; unsigned int cpu = 0; - p_data = kzalloc(sizeof(*p_data), GFP_KERNEL); + p_data = kzalloc_obj(*p_data, GFP_KERNEL); if (!p_data) return -ENOMEM; diff --git a/drivers/firmware/thead,th1520-aon.c b/drivers/firmware/thead,th1520-aon.c index 38f812ac9920..7dc871060c38 100644 --- a/drivers/firmware/thead,th1520-aon.c +++ b/drivers/firmware/thead,th1520-aon.c @@ -205,7 +205,7 @@ struct th1520_aon_chan *th1520_aon_init(struct device *dev) struct mbox_client *cl; int ret; - aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL); + aon_chan = kzalloc_obj(*aon_chan, GFP_KERNEL); if (!aon_chan) return ERR_PTR(-ENOMEM); diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index f15db1a818dc..fbe8510f4927 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -267,7 +267,7 @@ static int do_feature_check_call(const u32 api_id) } /* Add new entry if not present */ - feature_data = kmalloc(sizeof(*feature_data), GFP_ATOMIC); + feature_data = kmalloc_obj(*feature_data, GFP_ATOMIC); if (!feature_data) return -ENOMEM; |
