Commit 3a2c4d55e32a for kernel
commit 3a2c4d55e32ad65efebdb6de44eef3bfa08bb49d
Author: Kees Cook <kees+treewide@kernel.org>
Date: Wed Sep 2 15:31:14 2026 -0700
treewide: refresh kmalloc_obj() conversions
This is another run of the Coccinelle script for converting kmalloc()
family of allocations to kmalloc_obj() via the existing rules in
scripts/coccinelle/api/kmalloc_objs.cocci
This catches both the set of kmalloc() uses added since the first
kmalloc_obj() conversions in v7.0 and adds a large group missed in the
first pass due to Coccinelle not interacting well with the cleanup.h
scoped_...() family of macros[1]. I worked around this with spatch's
"--macro-file" argument to a file with all the scoped_...() macros mapped
to Coccinelle's YACFE_ITERATOR[2] as that was the closest viable control
flow indicator I could find.
Build tested allmodconfig on x86, arm64, arm, loongarch, mips, powerpc,
riscv, and s390 with no new warnings.
Link: https://lore.kernel.org/lkml/202609021314.8A9C0B8@keescook/ [1]
Link: https://github.com/coccinelle/coccinelle/blob/master/standard.h [2]
Signed-off-by: Kees Cook <kees+treewide@kernel.org>
diff --git a/arch/arm64/crypto/aes-neonbs-glue.c b/arch/arm64/crypto/aes-neonbs-glue.c
index 5bcbac979893..7cb1aede9a48 100644
--- a/arch/arm64/crypto/aes-neonbs-glue.c
+++ b/arch/arm64/crypto/aes-neonbs-glue.c
@@ -66,7 +66,7 @@ static int aesbs_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
struct crypto_aes_ctx *rk;
int err;
- rk = kmalloc(sizeof(*rk), GFP_KERNEL);
+ rk = kmalloc_obj(*rk);
if (!rk)
return -ENOMEM;
@@ -128,7 +128,7 @@ static int aesbs_cbc_ctr_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
struct crypto_aes_ctx *rk;
int err;
- rk = kmalloc(sizeof(*rk), GFP_KERNEL);
+ rk = kmalloc_obj(*rk);
if (!rk)
return -ENOMEM;
diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
index 17123f0b6dab..3c4fc566eafc 100644
--- a/arch/arm64/kvm/nested.c
+++ b/arch/arm64/kvm/nested.c
@@ -93,7 +93,7 @@ int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu)
num_mmus = atomic_read(&kvm->online_vcpus) * S2_MMU_PER_VCPU;
if (num_mmus > kvm->arch.nested_mmus_size) {
- tmp = kvcalloc(num_mmus, sizeof(*tmp), GFP_KERNEL_ACCOUNT);
+ tmp = kvzalloc_objs(*tmp, num_mmus, GFP_KERNEL_ACCOUNT);
if (!tmp)
return -ENOMEM;
diff --git a/arch/loongarch/kvm/intc/dmsintc.c b/arch/loongarch/kvm/intc/dmsintc.c
index bb7285c49df3..5518cafada55 100644
--- a/arch/loongarch/kvm/intc/dmsintc.c
+++ b/arch/loongarch/kvm/intc/dmsintc.c
@@ -149,7 +149,7 @@ static int kvm_dmsintc_create(struct kvm_device *dev, u32 type)
return -EINVAL;
}
- s = kzalloc(sizeof(struct loongarch_dmsintc), GFP_KERNEL);
+ s = kzalloc_obj(struct loongarch_dmsintc);
if (!s)
return -ENOMEM;
diff --git a/arch/mips/bcm47xx/buttons.c b/arch/mips/bcm47xx/buttons.c
index 151a4ee2803f..7bb338da8e42 100644
--- a/arch/mips/bcm47xx/buttons.c
+++ b/arch/mips/bcm47xx/buttons.c
@@ -523,24 +523,24 @@ bcm47xx_buttons_add(const struct bcm47xx_gpio_key *buttons, int nbuttons)
/* 1 node for gpio-keys device, 1 node for each button, 1 terminator */
const struct software_node **node_group __free(kfree) =
- kcalloc(1 + nbuttons + 1, sizeof(*node_group), GFP_KERNEL);
+ kzalloc_objs(*node_group, 1 + nbuttons + 1);
if (!node_group)
return -ENOMEM;
/* 1 code property, 1 gpio property, 1 terminator */
struct property_entry *props __free(kfree) =
- kcalloc(nbuttons * 3, sizeof(*props), GFP_KERNEL);
+ kzalloc_objs(*props, nbuttons * 3);
if (!props)
return -ENOMEM;
/* 1 node for gpio-keys device, 1 node for each button */
struct software_node *nodes __free(kfree) =
- kcalloc(1 + nbuttons, sizeof(*nodes), GFP_KERNEL);
+ kzalloc_objs(*nodes, 1 + nbuttons);
if (!nodes)
return -ENOMEM;
struct software_node_ref_args *ref_args __free(kfree) =
- kcalloc(nbuttons, sizeof(*ref_args), GFP_KERNEL);
+ kzalloc_objs(*ref_args, nbuttons);
if (!ref_args)
return -ENOMEM;
diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index 8ae088632337..ed3d3e26c136 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1134,7 +1134,7 @@ static int __init xive_init_ipis(void)
if (!ipi_domain)
goto out_free_fwnode;
- xive_ipis = kzalloc_objs(*xive_ipis, nr_node_ids, GFP_KERNEL);
+ xive_ipis = kzalloc_objs(*xive_ipis, nr_node_ids);
if (!xive_ipis)
goto out_free_domain;
diff --git a/arch/riscv/kvm/vcpu_pmu.c b/arch/riscv/kvm/vcpu_pmu.c
index 752f1014d633..6ff741ee7803 100644
--- a/arch/riscv/kvm/vcpu_pmu.c
+++ b/arch/riscv/kvm/vcpu_pmu.c
@@ -503,8 +503,8 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low
}
}
- einfo = kvcalloc(num_events, sizeof(*einfo),
- GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
+ einfo = kvzalloc_objs(*einfo, num_events,
+ GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
if (!einfo) {
ret = SBI_ERR_FAILURE;
goto out;
diff --git a/arch/s390/kvm/s390/s390.c b/arch/s390/kvm/s390/s390.c
index b0839e887221..5c73f43782a7 100644
--- a/arch/s390/kvm/s390/s390.c
+++ b/arch/s390/kvm/s390/s390.c
@@ -2168,7 +2168,7 @@ static int kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
return -EINVAL;
- keys = kvmalloc_array(args->count, sizeof(*keys), GFP_KERNEL_ACCOUNT);
+ keys = kvmalloc_objs(*keys, args->count, GFP_KERNEL_ACCOUNT);
if (!keys)
return -ENOMEM;
@@ -2205,7 +2205,7 @@ static int kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
return -EINVAL;
- keys = kvmalloc_array(args->count, sizeof(*keys), GFP_KERNEL_ACCOUNT);
+ keys = kvmalloc_objs(*keys, args->count, GFP_KERNEL_ACCOUNT);
if (!keys)
return -ENOMEM;
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index 3141f210fcd1..f40435505818 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -196,7 +196,7 @@ static int rocket_job_push(struct rocket_job *job)
if (check_add_overflow(job->in_bo_count, job->out_bo_count, &bo_count))
return -EINVAL;
- bos = kvmalloc_array(bo_count, sizeof(*bos), GFP_KERNEL);
+ bos = kvmalloc_objs(*bos, bo_count);
if (!bos)
return -ENOMEM;
memcpy(bos, job->in_bos, job->in_bo_count * sizeof(void *));
diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c
index e4293458bf61..a670722ddd5a 100644
--- a/drivers/acpi/irq.c
+++ b/drivers/acpi/irq.c
@@ -486,7 +486,8 @@ static u32 acpi_add_prt_dep(acpi_handle handle)
if (ACPI_FAILURE(status))
continue;
dep_devices.count = 1;
- dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL);
+ dep_devices.handles = kzalloc_objs(*dep_devices.handles,
+ 1);
if (!dep_devices.handles) {
acpi_handle_err(handle, "failed to allocate memory\n");
continue;
@@ -499,7 +500,8 @@ static u32 acpi_add_prt_dep(acpi_handle handle)
if (!gsi_handle)
continue;
dep_devices.count = 1;
- dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL);
+ dep_devices.handles = kzalloc_objs(*dep_devices.handles,
+ 1);
if (!dep_devices.handles) {
acpi_handle_err(handle, "failed to allocate memory\n");
continue;
@@ -526,7 +528,7 @@ static u32 acpi_add_irq_dep(acpi_handle handle)
continue;
dep_devices.count = 1;
- dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL);
+ dep_devices.handles = kzalloc_objs(*dep_devices.handles, 1);
if (!dep_devices.handles) {
acpi_handle_err(handle, "failed to allocate memory\n");
continue;
diff --git a/drivers/base/property.c b/drivers/base/property.c
index b136c339ddae..cceaa3240ca4 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -526,7 +526,7 @@ int fwnode_property_match_string(const struct fwnode_handle *fwnode,
if (nval == 0)
return -ENODATA;
- const char **values __free(kfree) = kcalloc(nval, sizeof(*values), GFP_KERNEL);
+ const char **values __free(kfree) = kzalloc_objs(*values, nval);
if (!values)
return -ENOMEM;
diff --git a/drivers/block/drbd/drbd_nl_gen.c b/drivers/block/drbd/drbd_nl_gen.c
index fb44b948cec8..9753dc789bde 100644
--- a/drivers/block/drbd/drbd_nl_gen.c
+++ b/drivers/block/drbd/drbd_nl_gen.c
@@ -656,7 +656,7 @@ static int __drbd_cfg_context_from_attrs(struct drbd_cfg_context *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_DRBD_CFG_CONTEXT_CTX_PEER_ADDR + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_DRBD_CFG_CONTEXT_CTX_PEER_ADDR + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_drbd_cfg_context_nl_policy, NULL);
@@ -714,7 +714,7 @@ static int __disk_conf_from_attrs(struct disk_conf *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_DISK_CONF_DISABLE_WRITE_SAME + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_DISK_CONF_DISABLE_WRITE_SAME + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_disk_conf_nl_policy, NULL);
@@ -871,7 +871,7 @@ static int __res_opts_from_attrs(struct res_opts *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_RES_OPTS_ON_NO_DATA + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_RES_OPTS_ON_NO_DATA + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_res_opts_nl_policy, NULL);
@@ -921,7 +921,7 @@ static int __net_conf_from_attrs(struct net_conf *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_NET_CONF_SOCK_CHECK_TIMEO + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_NET_CONF_SOCK_CHECK_TIMEO + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_net_conf_nl_policy, NULL);
@@ -1087,7 +1087,7 @@ static int __set_role_parms_from_attrs(struct set_role_parms *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_SET_ROLE_PARMS_ASSUME_UPTODATE + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_SET_ROLE_PARMS_ASSUME_UPTODATE + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_set_role_parms_nl_policy, NULL);
@@ -1133,7 +1133,7 @@ static int __resize_parms_from_attrs(struct resize_parms *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_RESIZE_PARMS_AL_STRIPE_SIZE + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_RESIZE_PARMS_AL_STRIPE_SIZE + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_resize_parms_nl_policy, NULL);
@@ -1195,7 +1195,7 @@ static int __start_ov_parms_from_attrs(struct start_ov_parms *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_START_OV_PARMS_OV_STOP_SECTOR + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_START_OV_PARMS_OV_STOP_SECTOR + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_start_ov_parms_nl_policy, NULL);
@@ -1245,7 +1245,7 @@ static int __new_c_uuid_parms_from_attrs(struct new_c_uuid_parms *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_NEW_C_UUID_PARMS_CLEAR_BM + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_NEW_C_UUID_PARMS_CLEAR_BM + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_new_c_uuid_parms_nl_policy, NULL);
@@ -1291,7 +1291,7 @@ static int __disconnect_parms_from_attrs(struct disconnect_parms *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_DISCONNECT_PARMS_FORCE_DISCONNECT + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_DISCONNECT_PARMS_FORCE_DISCONNECT + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_disconnect_parms_nl_policy, NULL);
@@ -1337,7 +1337,7 @@ static int __detach_parms_from_attrs(struct detach_parms *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_DETACH_PARMS_FORCE_DETACH + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_DETACH_PARMS_FORCE_DETACH + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_detach_parms_nl_policy, NULL);
@@ -1383,7 +1383,7 @@ static int __resource_info_from_attrs(struct resource_info *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_RESOURCE_INFO_RES_SUSP_FEN + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_RESOURCE_INFO_RES_SUSP_FEN + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_resource_info_nl_policy, NULL);
@@ -1441,7 +1441,7 @@ static int __device_info_from_attrs(struct device_info *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_DEVICE_INFO_DEV_DISK_STATE + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_DEVICE_INFO_DEV_DISK_STATE + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_device_info_nl_policy, NULL);
@@ -1487,7 +1487,7 @@ static int __connection_info_from_attrs(struct connection_info *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_CONNECTION_INFO_CONN_ROLE + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_CONNECTION_INFO_CONN_ROLE + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_connection_info_nl_policy, NULL);
@@ -1537,7 +1537,8 @@ static int __peer_device_info_from_attrs(struct peer_device_info *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_DEPENDENCY + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb,
+ DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_DEPENDENCY + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_peer_device_info_nl_policy, NULL);
@@ -1599,7 +1600,8 @@ static int __resource_statistics_from_attrs(struct resource_statistics *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_RESOURCE_STATISTICS_RES_STAT_WRITE_ORDERING + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb,
+ DRBD_A_RESOURCE_STATISTICS_RES_STAT_WRITE_ORDERING + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_resource_statistics_nl_policy, NULL);
@@ -1645,7 +1647,7 @@ static int __device_statistics_from_attrs(struct device_statistics *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_DEVICE_STATISTICS_HISTORY_UUIDS + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb, DRBD_A_DEVICE_STATISTICS_HISTORY_UUIDS + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_device_statistics_nl_policy, NULL);
@@ -1743,7 +1745,8 @@ static int __connection_statistics_from_attrs(struct connection_statistics *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_CONNECTION_STATISTICS_CONN_CONGESTED + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb,
+ DRBD_A_CONNECTION_STATISTICS_CONN_CONGESTED + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_connection_statistics_nl_policy, NULL);
@@ -1789,7 +1792,8 @@ static int __peer_device_statistics_from_attrs(struct peer_device_statistics *s,
*ret_nested_attribute_table = NULL;
if (!tla)
return -ENOMSG;
- ntb = kcalloc(DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_FLAGS + 1, sizeof(*ntb), GFP_KERNEL);
+ ntb = kzalloc_objs(*ntb,
+ DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_FLAGS + 1);
if (!ntb)
return -ENOMEM;
err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_peer_device_statistics_nl_policy, NULL);
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 6c5bec7da97c..47574a98fc86 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -5390,7 +5390,7 @@ static int __ublk_ctrl_reg_buf(struct ublk_device *ub,
page_to_pfn(pages[i + 1]) == pfn + (i - start) + 1)
i++;
- range = kzalloc(sizeof(*range), GFP_KERNEL);
+ range = kzalloc_obj(*range);
if (!range) {
ret = -ENOMEM;
goto unwind;
@@ -5453,7 +5453,7 @@ static int ublk_ctrl_reg_buf(struct ublk_device *ub,
nr_pages = buf_reg.len >> PAGE_SHIFT;
/* Pin pages before any locks (may sleep) */
- pages = kvmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL);
+ pages = kvmalloc_objs(*pages, nr_pages);
if (!pages)
return -ENOMEM;
diff --git a/drivers/block/zram/backend_lz4.c b/drivers/block/zram/backend_lz4.c
index 1e28104ad964..1e4ad31d39a6 100644
--- a/drivers/block/zram/backend_lz4.c
+++ b/drivers/block/zram/backend_lz4.c
@@ -42,7 +42,7 @@ static int lz4_setup_params(struct zcomp_params *params)
if (!params->dict || !params->dict_sz)
return 0;
- dict_stream = kzalloc_obj(*dict_stream, GFP_KERNEL);
+ dict_stream = kzalloc_obj(*dict_stream);
if (!dict_stream)
return -ENOMEM;
diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c
index 01eae8995254..83c3592cd179 100644
--- a/drivers/clk/ti/composite.c
+++ b/drivers/clk/ti/composite.c
@@ -248,7 +248,7 @@ int __init ti_clk_add_component(struct device_node *node, struct clk_hw *hw,
return -EINVAL;
}
- parent_data = kcalloc(num_parents, sizeof(*parent_data), GFP_KERNEL);
+ parent_data = kzalloc_objs(*parent_data, num_parents);
if (!parent_data)
return -ENOMEM;
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c
index 0fef60e82107..baf90a3fb49e 100644
--- a/drivers/clk/ti/mux.c
+++ b/drivers/clk/ti/mux.c
@@ -181,7 +181,7 @@ static void of_mux_clk_setup(struct device_node *node)
pr_err("mux-clock %pOFn must have parents\n", node);
return;
}
- parent_data = kcalloc(num_parents, sizeof(*parent_data), GFP_KERNEL);
+ parent_data = kzalloc_objs(*parent_data, num_parents);
if (!parent_data)
return;
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index d4ff8b228f86..8bfd46d60843 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -1624,7 +1624,7 @@ static struct freq_attr **get_freq_attrs(void)
/* amd_pstate_{max_freq, lowest_nonlinear_freq, highest_perf} should always be visible */
BUG_ON(!count);
- attrs = kcalloc(count + 1, sizeof(struct freq_attr *), GFP_KERNEL);
+ attrs = kzalloc_objs(struct freq_attr *, count + 1);
if (!attrs)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/crypto/inside-secure/eip93/eip93-common.c b/drivers/crypto/inside-secure/eip93/eip93-common.c
index 4c163d7281b3..dacf586b2641 100644
--- a/drivers/crypto/inside-secure/eip93/eip93-common.c
+++ b/drivers/crypto/inside-secure/eip93/eip93-common.c
@@ -533,7 +533,7 @@ int eip93_send_req(struct crypto_async_request *async,
memcpy(iv, reqiv, rctx->ivsize);
- rctx->sa_state = kzalloc(sizeof(*rctx->sa_state), GFP_KERNEL);
+ rctx->sa_state = kzalloc_obj(*rctx->sa_state);
if (!rctx->sa_state)
return -ENOMEM;
@@ -561,8 +561,7 @@ int eip93_send_req(struct crypto_async_request *async,
iv[3] = 0xffffffff;
crypto_inc((u8 *)iv, AES_BLOCK_SIZE);
- rctx->sa_state_ctr = kzalloc(sizeof(*rctx->sa_state_ctr),
- GFP_KERNEL);
+ rctx->sa_state_ctr = kzalloc_obj(*rctx->sa_state_ctr);
if (!rctx->sa_state_ctr) {
err = -ENOMEM;
goto free_sa_state;
diff --git a/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c b/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
index e0d003b50358..50e444da97e6 100644
--- a/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
+++ b/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
@@ -59,8 +59,7 @@ static void *qat_zstd_alloc_scratch(void)
if (!scratch->literals)
goto error;
- scratch->out_seqs = kvcalloc(QAT_MAX_SEQUENCES, sizeof(ZSTD_Sequence),
- GFP_KERNEL);
+ scratch->out_seqs = kvzalloc_objs(ZSTD_Sequence, QAT_MAX_SEQUENCES);
if (!scratch->out_seqs)
goto error;
diff --git a/drivers/crypto/ti/dthev2-aes.c b/drivers/crypto/ti/dthev2-aes.c
index eb5cd902dfb5..a3c069ca2baf 100644
--- a/drivers/crypto/ti/dthev2-aes.c
+++ b/drivers/crypto/ti/dthev2-aes.c
@@ -387,7 +387,7 @@ static int dthe_aes_run(struct crypto_engine *engine, void *areq)
src_nents++;
dst_nents++;
- src = kmalloc_array(src_nents, sizeof(*src), GFP_ATOMIC);
+ src = kmalloc_objs(*src, src_nents, GFP_ATOMIC);
if (!src) {
ret = -ENOMEM;
goto aes_ctr_src_alloc_err;
@@ -399,7 +399,7 @@ static int dthe_aes_run(struct crypto_engine *engine, void *areq)
sg_set_buf(sg, pad_buf, pad_size);
if (diff_dst) {
- dst = kmalloc_array(dst_nents, sizeof(*dst), GFP_ATOMIC);
+ dst = kmalloc_objs(*dst, dst_nents, GFP_ATOMIC);
if (!dst) {
ret = -ENOMEM;
goto aes_ctr_dst_alloc_err;
@@ -624,7 +624,7 @@ static struct scatterlist *dthe_aead_prep_aad(struct scatterlist *sg,
if (assoclen % AES_BLOCK_SIZE)
aad_nents++;
- aad_sg = kmalloc_array(aad_nents, sizeof(struct scatterlist), GFP_ATOMIC);
+ aad_sg = kmalloc_objs(struct scatterlist, aad_nents, GFP_ATOMIC);
if (!aad_sg)
return ERR_PTR(-ENOMEM);
@@ -680,7 +680,7 @@ static struct scatterlist *dthe_aead_prep_crypt(struct scatterlist *sg,
if (cryptlen % AES_BLOCK_SIZE)
crypt_nents++;
- crypt_sg = kmalloc_array(crypt_nents, sizeof(struct scatterlist), GFP_ATOMIC);
+ crypt_sg = kmalloc_objs(struct scatterlist, crypt_nents, GFP_ATOMIC);
if (!crypt_sg) {
err = -ENOMEM;
goto dthe_aead_prep_crypt_mem_err;
diff --git a/drivers/devfreq/hisi_uncore_freq.c b/drivers/devfreq/hisi_uncore_freq.c
index e1f64b723082..ac55641b0259 100644
--- a/drivers/devfreq/hisi_uncore_freq.c
+++ b/drivers/devfreq/hisi_uncore_freq.c
@@ -474,7 +474,7 @@ static int hisi_uncore_mark_related_cpus(struct hisi_uncore_freq *uncore,
return -EINVAL;
len = rc;
- u32 *num __free(kfree) = kcalloc(len, sizeof(*num), GFP_KERNEL);
+ u32 *num __free(kfree) = kzalloc_objs(*num, len);
if (!num)
return -ENOMEM;
diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-fence.c
index 856d0d302a5d..cb62e606d0a2 100644
--- a/drivers/dma-buf/st-dma-fence.c
+++ b/drivers/dma-buf/st-dma-fence.c
@@ -27,7 +27,7 @@ static struct dma_fence *mock_fence(void)
{
struct dma_fence *f;
- f = kmalloc(sizeof(*f), GFP_KERNEL);
+ f = kmalloc_obj(*f);
if (!f)
return NULL;
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index 4a9ab5822ffc..df6dd0046242 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -359,7 +359,7 @@ static long udmabuf_create(struct miscdevice *device,
long ret = -EINVAL;
u32 i, flags;
- ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL);
+ ubuf = kzalloc_obj(*ubuf);
if (!ubuf)
return -ENOMEM;
@@ -387,7 +387,7 @@ static long udmabuf_create(struct miscdevice *device,
if (ret)
goto err;
- folios = kvmalloc_array(max_nr_folios, sizeof(*folios), GFP_KERNEL);
+ folios = kvmalloc_objs(*folios, max_nr_folios);
if (!folios) {
ret = -ENOMEM;
goto err;
diff --git a/drivers/dma/switchtec_dma.c b/drivers/dma/switchtec_dma.c
index c133535d3765..c8e2169877e9 100644
--- a/drivers/dma/switchtec_dma.c
+++ b/drivers/dma/switchtec_dma.c
@@ -1056,7 +1056,7 @@ static int switchtec_dma_chan_init(struct switchtec_dma_dev *swdma_dev,
int se_buf_len, irq, rc;
struct dma_chan *chan;
- swdma_chan = kzalloc_obj(*swdma_chan, GFP_KERNEL);
+ swdma_chan = kzalloc_obj(*swdma_chan);
if (!swdma_chan)
return -ENOMEM;
@@ -1162,8 +1162,7 @@ static int switchtec_dma_chans_enumerate(struct switchtec_dma_dev *swdma_dev,
struct dma_device *dma = &swdma_dev->dma_dev;
int base, cnt, rc, i;
- swdma_dev->swdma_chans = kcalloc(chan_cnt, sizeof(*swdma_dev->swdma_chans),
- GFP_KERNEL);
+ swdma_dev->swdma_chans = kzalloc_objs(*swdma_dev->swdma_chans, chan_cnt);
if (!swdma_dev->swdma_chans)
return -ENOMEM;
@@ -1222,7 +1221,7 @@ static int switchtec_dma_create(struct pci_dev *pdev)
/*
* Create the switchtec dma device
*/
- swdma_dev = kzalloc_obj(*swdma_dev, GFP_KERNEL);
+ swdma_dev = kzalloc_obj(*swdma_dev);
if (!swdma_dev)
return -ENOMEM;
diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
index 97ec05d68bbb..9e65c4b1d99d 100644
--- a/drivers/edac/versalnet_edac.c
+++ b/drivers/edac/versalnet_edac.c
@@ -813,7 +813,7 @@ static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i
layers[1].is_virt_csrow = false;
rc = -ENOMEM;
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kzalloc_obj(*dev);
if (!dev)
return rc;
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index ef29fd223287..922777e86d58 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -1792,7 +1792,7 @@ static void *scmi_iterator_init(const struct scmi_protocol_handle *ph,
{
int ret;
- struct scmi_iterator *i __free(kfree) = kzalloc(sizeof(*i), GFP_KERNEL);
+ struct scmi_iterator *i __free(kfree) = kzalloc_obj(*i);
if (!i)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c
index 0fd9581275f1..f926c1f64822 100644
--- a/drivers/firmware/qcom/qcom_tzmem.c
+++ b/drivers/firmware/qcom/qcom_tzmem.c
@@ -169,7 +169,7 @@ static int qcom_tzmem_init_area(struct qcom_tzmem_area *area)
{
int ret;
- u64 *handle __free(kfree) = kzalloc(sizeof(*handle), GFP_KERNEL);
+ u64 *handle __free(kfree) = kzalloc_obj(*handle);
if (!handle)
return -ENOMEM;
@@ -197,8 +197,7 @@ static int qcom_tzmem_pool_add_memory(struct qcom_tzmem_pool *pool,
{
int ret;
- struct qcom_tzmem_area *area __free(kfree) = kzalloc(sizeof(*area),
- gfp);
+ struct qcom_tzmem_area *area __free(kfree) = kzalloc_obj(*area, gfp);
if (!area)
return -ENOMEM;
@@ -415,8 +414,7 @@ void *qcom_tzmem_alloc(struct qcom_tzmem_pool *pool, size_t size, gfp_t gfp)
size = PAGE_ALIGN(size);
- struct qcom_tzmem_chunk *chunk __free(kfree) = kzalloc(sizeof(*chunk),
- gfp);
+ struct qcom_tzmem_chunk *chunk __free(kfree) = kzalloc_obj(*chunk, gfp);
if (!chunk)
return NULL;
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index cc747ab0237f..33d7c4a4181e 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -2386,7 +2386,7 @@ static int ti_sci_set_irq(const struct ti_sci_handle *handle, u32 valid_params,
if (ret || !(info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST))
goto end;
- irq = kzalloc_obj(*irq, GFP_KERNEL);
+ irq = kzalloc_obj(*irq);
if (!irq) {
ti_sci_manage_irq(handle, valid_params, src_id, src_index,
dst_id, dst_host_irq, ia_id, vint,
diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c
index 87652d58d03f..1b3a1af8658d 100644
--- a/drivers/fpga/dfl-afu-dma-region.c
+++ b/drivers/fpga/dfl-afu-dma-region.c
@@ -316,7 +316,7 @@ int afu_dma_map_region(struct dfl_feature_dev_data *fdata,
if (user_addr + length < user_addr)
return -EINVAL;
- region = kzalloc(sizeof(*region), GFP_KERNEL);
+ region = kzalloc_obj(*region);
if (!region)
return -ENOMEM;
diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index 5ce89f52b4b5..b0b65416d74d 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -886,8 +886,8 @@ gpio_aggregator_make_device_sw_node(struct gpio_aggregator *aggr)
if (num_lines == 0)
return NULL;
- const char **line_names __free(kfree) = kcalloc(
- num_lines, sizeof(*line_names), GFP_KERNEL);
+ const char **line_names __free(kfree) = kzalloc_objs(*line_names,
+ num_lines);
if (!line_names)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpio/gpio-mpsse.c b/drivers/gpio/gpio-mpsse.c
index a859deab2bca..30e8009b5fcc 100644
--- a/drivers/gpio/gpio-mpsse.c
+++ b/drivers/gpio/gpio-mpsse.c
@@ -518,7 +518,7 @@ static void gpio_mpsse_irq_enable(struct irq_data *irqd)
* Can't be devm because it uses a non-raw spinlock (illegal in
* this context, where a raw spinlock is held by our caller)
*/
- worker = kzalloc(sizeof(*worker), GFP_NOWAIT);
+ worker = kzalloc_obj(*worker, GFP_NOWAIT);
if (!worker)
return;
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index ef1b779e8ea6..0c73bec04267 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -790,8 +790,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank,
line_names_size = gpio_sim_get_line_names_size(bank);
if (line_names_size) {
- line_names = kcalloc(line_names_size, sizeof(*line_names),
- GFP_KERNEL);
+ line_names = kzalloc_objs(*line_names, line_names_size);
if (!line_names)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpio/gpio-virtuser.c b/drivers/gpio/gpio-virtuser.c
index 7d0d366be37a..449fb1aed24b 100644
--- a/drivers/gpio/gpio-virtuser.c
+++ b/drivers/gpio/gpio-virtuser.c
@@ -1429,8 +1429,7 @@ gpio_virtuser_make_device_swnode(struct gpio_virtuser_device *dev)
memset(properties, 0, sizeof(properties));
num_ids = list_count_nodes(&dev->lookup_list);
- char **ids __free(kfree) = kcalloc(num_ids + 1, sizeof(*ids),
- GFP_KERNEL);
+ char **ids __free(kfree) = kzalloc_objs(*ids, num_ids + 1);
if (!ids)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index 9f3b628d5793..d1105b7ae437 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -2653,7 +2653,7 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)
struct gpio_chardev_data *cdev;
int ret = -ENOMEM;
- cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
+ cdev = kzalloc_obj(*cdev);
if (!cdev)
return -ENOMEM;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index ef8ccaf17c9c..66d2325bfae8 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1178,7 +1178,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
int base = 0;
int ret;
- gdev = kzalloc(sizeof(*gdev), GFP_KERNEL);
+ gdev = kzalloc_obj(*gdev);
if (!gdev)
return -ENOMEM;
gc->gpiodev = gdev;
@@ -1218,7 +1218,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
goto err_put_device;
gdev->ngpio = gc->ngpio;
- gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL);
+ gdev->descs = kzalloc_objs(*gdev->descs, gc->ngpio);
if (!gdev->descs) {
ret = -ENOMEM;
goto err_put_device;
diff --git a/drivers/gpu/buddy.c b/drivers/gpu/buddy.c
index a5553fcec28c..26e7a48b55f3 100644
--- a/drivers/gpu/buddy.c
+++ b/drivers/gpu/buddy.c
@@ -411,16 +411,13 @@ int gpu_buddy_init(struct gpu_buddy *mm, u64 size, u64 chunk_size)
if (!mm->used_scoreboard)
goto out_free_free_scoreboard;
- mm->free_trees = kmalloc_array(GPU_BUDDY_MAX_FREE_TREES,
- sizeof(*mm->free_trees),
- GFP_KERNEL);
+ mm->free_trees = kmalloc_objs(*mm->free_trees, GPU_BUDDY_MAX_FREE_TREES);
if (!mm->free_trees)
goto out_free_used_scoreboard;
for_each_free_tree(i) {
- mm->free_trees[i] = kmalloc_array(mm->max_order + 1,
- sizeof(struct rb_root),
- GFP_KERNEL);
+ mm->free_trees[i] = kmalloc_objs(struct rb_root,
+ mm->max_order + 1);
if (!mm->free_trees[i])
goto out_free_tree;
@@ -430,9 +427,7 @@ int gpu_buddy_init(struct gpu_buddy *mm, u64 size, u64 chunk_size)
mm->n_roots = hweight64(size);
- mm->roots = kmalloc_array(mm->n_roots,
- sizeof(struct gpu_buddy_block *),
- GFP_KERNEL);
+ mm->roots = kmalloc_objs(struct gpu_buddy_block *, mm->n_roots);
if (!mm->roots)
goto out_free_tree;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 87e15e39eb30..6ff9ffe47f35 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -603,9 +603,8 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
ring_count++;
}
if (ring_count)
- coredump->rings = kvcalloc(ring_count,
- sizeof(struct amdgpu_coredump_ring),
- GFP_NOWAIT);
+ coredump->rings = kvzalloc_objs(struct amdgpu_coredump_ring,
+ ring_count, GFP_NOWAIT);
if (coredump->rings) {
for (i = 0, idx = 0; i < adev->num_rings && idx < ring_count; i++) {
struct amdgpu_coredump_ring *cdump_ring;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index 164e85b66e2d..62f5c5cbd7f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -1608,11 +1608,11 @@ int amdgpu_discovery_sysfs_early_init(struct amdgpu_device *adev, struct pci_dev
discovery_bin = adev->discovery.bin;
- early_entry = kzalloc(sizeof(*early_entry), GFP_KERNEL);
+ early_entry = kzalloc_obj(*early_entry);
if (!early_entry)
return -ENOMEM;
- ip_top = kzalloc(sizeof(*ip_top), GFP_KERNEL);
+ ip_top = kzalloc_obj(*ip_top);
if (!ip_top) {
kfree(early_entry);
return -ENOMEM;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c
index d5787d848d04..4a7f63fb2fad 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c
@@ -98,7 +98,7 @@ int amdgpu_lockdep_init(void)
struct amdgpu_lockdep_dummy_locks *locks;
unsigned long flags;
- locks = kzalloc(sizeof(*locks), GFP_KERNEL);
+ locks = kzalloc_obj(*locks);
if (!locks)
return -ENOMEM;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
index 95468b9463fb..78adfc839ef8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
@@ -1293,7 +1293,7 @@ amdgpu_ras_debugfs_table_read_uniras(struct amdgpu_device *adev,
return -ENOMEM;
if (num_recs) {
- records = kvcalloc(num_recs, sizeof(*records), GFP_KERNEL);
+ records = kvzalloc_objs(*records, num_recs);
if (!records) {
res = -ENOMEM;
goto out;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index d5a419776e93..05abf4c31dce 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2361,9 +2361,8 @@ void amdgpu_ttm_enable_buffer_funcs(struct amdgpu_device *adev)
num_clear_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES);
num_move_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES);
- adev->mman.clear_entities = kcalloc(num_clear_entities,
- sizeof(struct amdgpu_ttm_buffer_entity),
- GFP_KERNEL);
+ adev->mman.clear_entities = kzalloc_objs(struct amdgpu_ttm_buffer_entity,
+ num_clear_entities);
atomic_set(&adev->mman.next_clear_entity, 0);
if (!adev->mman.clear_entities)
goto error_free_default_entity;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c
index a98a6cfd4fba..71d34fd09385 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c
@@ -159,8 +159,8 @@ void amdgpu_umc_handle_bad_pages(struct amdgpu_device *adev,
adev->umc.ras->ecc_info_query_ras_error_address &&
adev->umc.max_ras_err_cnt_per_query) {
err_data->err_addr =
- kcalloc(adev->umc.max_ras_err_cnt_per_query,
- sizeof(struct eeprom_table_record), GFP_KERNEL);
+ kzalloc_objs(struct eeprom_table_record,
+ adev->umc.max_ras_err_cnt_per_query);
/* still call query_ras_error_address to clear error status
* even NOMEM error is encountered
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
index 4b023e024d9f..743b41db5b7c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -227,7 +227,7 @@ static int amdgpu_userq_fence_alloc(struct amdgpu_usermode_queue *userq,
struct amdgpu_userq_fence *userq_fence;
void *entry;
- userq_fence = kmalloc(sizeof(*userq_fence), GFP_KERNEL);
+ userq_fence = kmalloc_obj(*userq_fence);
if (!userq_fence)
return -ENOMEM;
@@ -244,9 +244,7 @@ static int amdgpu_userq_fence_alloc(struct amdgpu_usermode_queue *userq,
} while (xas_retry(&xas, entry));
rcu_read_unlock();
- userq_fence->fence_drv_array = kvmalloc_array(xas.xa_index,
- sizeof(fence_drv),
- GFP_KERNEL);
+ userq_fence->fence_drv_array = kvmalloc_objs(fence_drv, xas.xa_index);
if (!userq_fence->fence_drv_array) {
mutex_unlock(&userq->fence_drv_lock);
kfree(userq_fence);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index b43fc643668d..7a007f4916bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -316,8 +316,8 @@ static int amdgpu_virt_ras_realloc_eh_data_space(struct amdgpu_device *adev,
if (align_space > AMDGPU_VIRT_RAS_BAD_PAGE_TABLE_MAX_CAPACITY)
return -ENOMEM;
- new_bps = kmalloc_array(align_space, sizeof(*data->bps), GFP_KERNEL);
- new_bo = kcalloc(align_space, sizeof(*data->bps_bo), GFP_KERNEL);
+ new_bps = kmalloc_objs(*data->bps, align_space);
+ new_bo = kzalloc_objs(*data->bps_bo, align_space);
if (!new_bps || !new_bo) {
kfree(new_bps);
kfree(new_bo);
@@ -355,7 +355,7 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
if (!bps)
goto bps_failure;
- bps_bo = kcalloc(align_space, sizeof(*(*data)->bps_bo), GFP_KERNEL);
+ bps_bo = kzalloc_objs(*(*data)->bps_bo, align_space);
if (!bps_bo)
goto bps_bo_failure;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 7fcfc150a7fc..504a286368eb 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1921,13 +1921,13 @@ static int criu_checkpoint_devices(struct kfd_process *p,
struct kfd_criu_device_bucket *device_buckets = NULL;
int ret = 0, i;
- device_buckets = kvcalloc(num_devices, sizeof(*device_buckets), GFP_KERNEL);
+ device_buckets = kvzalloc_objs(*device_buckets, num_devices);
if (!device_buckets) {
ret = -ENOMEM;
goto exit;
}
- device_priv = kvcalloc(num_devices, sizeof(*device_priv), GFP_KERNEL);
+ device_priv = kvzalloc_objs(*device_priv, num_devices);
if (!device_priv) {
ret = -ENOMEM;
goto exit;
@@ -2047,17 +2047,17 @@ static int criu_checkpoint_bos(struct kfd_process *p,
int ret = 0, pdd_index, bo_index = 0, id;
void *mem;
- bo_buckets = kvcalloc(num_bos, sizeof(*bo_buckets), GFP_KERNEL);
+ bo_buckets = kvzalloc_objs(*bo_buckets, num_bos);
if (!bo_buckets)
return -ENOMEM;
- bo_privs = kvcalloc(num_bos, sizeof(*bo_privs), GFP_KERNEL);
+ bo_privs = kvzalloc_objs(*bo_privs, num_bos);
if (!bo_privs) {
ret = -ENOMEM;
goto exit;
}
- files = kvcalloc(num_bos, sizeof(struct file *), GFP_KERNEL);
+ files = kvzalloc_objs(struct file *, num_bos);
if (!files) {
ret = -ENOMEM;
goto exit;
@@ -2588,7 +2588,7 @@ static int criu_restore_bos(struct kfd_process *p,
if (!bo_buckets)
return -ENOMEM;
- files = kvcalloc(args->num_bos, sizeof(struct file *), GFP_KERNEL);
+ files = kvzalloc_objs(struct file *, args->num_bos);
if (!files) {
ret = -ENOMEM;
goto exit;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
index a54fd9529dc9..0d2f9dbce0a9 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
@@ -4180,7 +4180,7 @@ dm_test_destroy_connector(struct kunit *test, struct drm_device *drm)
{
struct amdgpu_dm_connector *aconnector;
- aconnector = kzalloc(sizeof(*aconnector), GFP_KERNEL);
+ aconnector = kzalloc_obj(*aconnector);
KUNIT_ASSERT_NOT_NULL(test, aconnector);
KUNIT_ASSERT_EQ(test,
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
index 4dacddd23878..0d998f204250 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
@@ -1445,7 +1445,7 @@ static void dm_test_crtc_destroy_state_no_stream(struct kunit *test)
struct dm_crtc_state *dm_state;
/* destroy_state kfree()s the state, so use a plain (unmanaged) alloc. */
- dm_state = kzalloc_obj(*dm_state, GFP_KERNEL);
+ dm_state = kzalloc_obj(*dm_state);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm_state);
amdgpu_dm_crtc_destroy_state(NULL, &dm_state->base);
@@ -1475,7 +1475,7 @@ static void dm_test_crtc_destroy_state_releases_stream(struct kunit *test)
kref_get(&stream->refcount);
/* destroy_state kfree()s the state, so use a plain (unmanaged) alloc. */
- dm_state = kzalloc_obj(*dm_state, GFP_KERNEL);
+ dm_state = kzalloc_obj(*dm_state);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm_state);
dm_state->stream = stream;
@@ -1569,7 +1569,7 @@ static void dm_test_crtc_handle_vblank_completes_cursor_only(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, acrtc);
/* drm_crtc_send_vblank_event() consumes (kfree()s) the event. */
- event = kzalloc_obj(*event, GFP_KERNEL);
+ event = kzalloc_obj(*event);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, event);
acrtc->base.dev = &adev->ddev;
@@ -1628,7 +1628,7 @@ dm_test_vblank_control_worker_setup(struct kunit *test, bool enable,
kref_get(&stream->refcount);
/* Worker kfree()s the work item, so it must be a plain allocation. */
- work = kzalloc_obj(*work, GFP_KERNEL);
+ work = kzalloc_obj(*work);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, work);
work->dm = &adev->dm;
work->acrtc = acrtc;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
index 28c36217f6a2..861ee9eaa032 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
@@ -103,7 +103,7 @@ static enum dc_status dm_test_dp_read_hpd_rx_irq_data_ok(struct dc_link *link,
*/
static struct dc_sink *dm_test_sink_create(struct dc_link *link)
{
- struct dc_sink *sink = kzalloc(sizeof(*sink), GFP_KERNEL);
+ struct dc_sink *sink = kzalloc_obj(*sink);
if (!sink)
return NULL;
@@ -2131,7 +2131,7 @@ static void dm_test_hpd_rx_offload_work_no_connector(struct kunit *test)
offload_wq = kunit_kzalloc(test, sizeof(*offload_wq), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_wq);
- offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL);
+ offload_work = kzalloc_obj(*offload_work);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work);
offload_work->offload_wq = offload_wq;
offload_work->adev = adev;
@@ -2177,7 +2177,7 @@ static void dm_test_hpd_rx_offload_work_no_connection(struct kunit *test)
link->dc = dc;
aconn->dc_link = link;
- offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL);
+ offload_work = kzalloc_obj(*offload_work);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work);
offload_work->offload_wq = offload_wq;
offload_work->adev = adev;
@@ -2244,7 +2244,7 @@ static void dm_test_hpd_rx_offload_work_automated_test(struct kunit *test)
link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT;
aconn->dc_link = link;
- offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL);
+ offload_work = kzalloc_obj(*offload_work);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work);
offload_work->offload_wq = offload_wq;
offload_work->adev = adev;
@@ -2315,7 +2315,7 @@ static void dm_test_hpd_rx_offload_work_link_loss(struct kunit *test)
link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT;
aconn->dc_link = link;
- offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL);
+ offload_work = kzalloc_obj(*offload_work);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work);
offload_work->offload_wq = offload_wq;
offload_work->adev = adev;
@@ -3452,9 +3452,9 @@ static void dm_test_handle_hpd_work_out_of_range(struct kunit *test)
struct amdgpu_device *adev;
adev = dm_kunit_alloc_adev(test);
- hpd_work = kzalloc(sizeof(*hpd_work), GFP_KERNEL);
+ hpd_work = kzalloc_obj(*hpd_work);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hpd_work);
- hpd_work->dmub_notify = kzalloc(sizeof(*hpd_work->dmub_notify), GFP_KERNEL);
+ hpd_work->dmub_notify = kzalloc_obj(*hpd_work->dmub_notify);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hpd_work->dmub_notify);
hpd_work->dmub_notify->type =
(enum dmub_notification_type)ARRAY_SIZE(adev->dm.dmub_callback);
@@ -3899,9 +3899,9 @@ static void dm_test_handle_vmin_vmax_update(struct kunit *test)
kref_get(&stream->refcount);
/* The worker kfree()s both, so they must come from the slab. */
- work = kzalloc(sizeof(*work), GFP_KERNEL);
+ work = kzalloc_obj(*work);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, work);
- adjust = kzalloc(sizeof(*adjust), GFP_KERNEL);
+ adjust = kzalloc_obj(*adjust);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adjust);
work->adev = adev;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c
index ba97092c7bb8..23ac8ae41c68 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c
@@ -2945,7 +2945,7 @@ static void dm_test_plane_reset_initializes_state(struct kunit *test)
* destroy-existing-state path. The destroy hook frees this state, so it
* must be a plain (non-KUnit-managed) allocation.
*/
- old_state = kzalloc(sizeof(*old_state), GFP_KERNEL);
+ old_state = kzalloc_obj(*old_state);
KUNIT_ASSERT_NOT_NULL(test, old_state);
plane->funcs = &dm_test_plane_reset_funcs;
plane->state = &old_state->base;
@@ -3018,7 +3018,7 @@ static void dm_test_plane_destroy_state_minimal(struct kunit *test)
KUNIT_ASSERT_NOT_NULL(test, plane);
/* destroy_state frees the state itself, so use a plain allocation. */
- dm_plane_state = kzalloc(sizeof(*dm_plane_state), GFP_KERNEL);
+ dm_plane_state = kzalloc_obj(*dm_plane_state);
KUNIT_ASSERT_NOT_NULL(test, dm_plane_state);
amdgpu_dm_plane_drm_plane_destroy_state(plane, &dm_plane_state->base);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
index 3c10eec9b1e0..5645866610fc 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
@@ -239,7 +239,7 @@ static void dm_test_atomic_destroy_state_no_context(struct kunit *test)
* Use kzalloc(), not kunit_kzalloc(): dm_atomic_destroy_state() frees
* the state itself, so KUnit-managed memory would be double-freed.
*/
- dm_state = kzalloc(sizeof(*dm_state), GFP_KERNEL);
+ dm_state = kzalloc_obj(*dm_state);
KUNIT_ASSERT_NOT_NULL(test, dm_state);
/* context == NULL: dc_state_release() is skipped and the state is freed. */
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c
index e2148cb3b8ab..bf80eaf23e9a 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c
@@ -377,7 +377,7 @@ struct clk_mgr *dc_clk_mgr_create(struct dc_context *ctx, struct pp_smu_funcs *p
}
break;
case AMDGPU_FAMILY_GC_11_5_4: {
- struct clk_mgr_dcn42 *clk_mgr = kzalloc(sizeof(*clk_mgr), GFP_KERNEL);
+ struct clk_mgr_dcn42 *clk_mgr = kzalloc_obj(*clk_mgr);
if (clk_mgr == NULL) {
BREAK_TO_DEBUGGER();
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c
index d71b0aed90c9..7dd88d90eba2 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c
@@ -1595,7 +1595,7 @@ struct clk_mgr_internal *dcn60_clk_mgr_construct(
struct dccg *dccg)
{
struct clk_log_info log_info = {0};
- struct dcn60_clk_mgr *clk_mgr60 = kzalloc(sizeof(struct dcn60_clk_mgr), GFP_KERNEL);
+ struct dcn60_clk_mgr *clk_mgr60 = kzalloc_obj(struct dcn60_clk_mgr);
struct clk_mgr_internal *clk_mgr;
if (!clk_mgr60)
@@ -1644,7 +1644,7 @@ struct clk_mgr_internal *dcn60_clk_mgr_construct(
clk_mgr->smu_present = false;
- clk_mgr->base.bw_params = kzalloc(sizeof(*clk_mgr->base.bw_params), GFP_KERNEL);
+ clk_mgr->base.bw_params = kzalloc_obj(*clk_mgr->base.bw_params);
if (!clk_mgr->base.bw_params)
goto fail;
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 68f228014305..a98ed4617a03 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -914,8 +914,7 @@ static bool dc_construct_update_scratch_pool(struct dc *dc)
unsigned int i;
for (i = 0; i < ARRAY_SIZE(dc->update_scratch_pool); i++) {
- dc->update_scratch_pool[i] = kzalloc(
- sizeof(struct dc_update_scratch_space), GFP_KERNEL);
+ dc->update_scratch_pool[i] = kzalloc_obj(struct dc_update_scratch_space);
if (!dc->update_scratch_pool[i])
return false;
dc->update_scratch_in_use[i] = false;
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
index 88e825a6582c..0b135a9e6c4f 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
@@ -290,7 +290,7 @@ static void dc_plane_cm_free(struct kref *kref)
struct dc_plane_cm *dc_plane_cm_create(void)
{
- struct dc_plane_cm *cm = kvzalloc(sizeof(*cm), GFP_KERNEL);
+ struct dc_plane_cm *cm = kvzalloc_obj(*cm);
if (cm == NULL)
goto alloc_fail;
diff --git a/drivers/gpu/drm/amd/display/dc/dccg/dcn42/dcn42_dccg.c b/drivers/gpu/drm/amd/display/dc/dccg/dcn42/dcn42_dccg.c
index 3b03b152da22..c2fa7fd56acf 100644
--- a/drivers/gpu/drm/amd/display/dc/dccg/dcn42/dcn42_dccg.c
+++ b/drivers/gpu/drm/amd/display/dc/dccg/dcn42/dcn42_dccg.c
@@ -358,7 +358,7 @@ struct dccg *dccg42_create(
const struct dccg_shift *dccg_shift,
const struct dccg_mask *dccg_mask)
{
- struct dcn_dccg *dccg_dcn = kzalloc(sizeof(*dccg_dcn), GFP_KERNEL);
+ struct dcn_dccg *dccg_dcn = kzalloc_obj(*dccg_dcn);
struct dccg *base;
if (dccg_dcn == NULL) {
diff --git a/drivers/gpu/drm/amd/display/dc/dccg/dcn60/dcn60_dccg.c b/drivers/gpu/drm/amd/display/dc/dccg/dcn60/dcn60_dccg.c
index 8e2f88913e4c..1d6d193b23c7 100644
--- a/drivers/gpu/drm/amd/display/dc/dccg/dcn60/dcn60_dccg.c
+++ b/drivers/gpu/drm/amd/display/dc/dccg/dcn60/dcn60_dccg.c
@@ -167,7 +167,7 @@ struct dccg *dccg60_create(
const struct dccg_shift *dccg_shift,
const struct dccg_mask *dccg_mask)
{
- struct dcn_dccg *dccg_dcn = kzalloc(sizeof(*dccg_dcn), GFP_KERNEL);
+ struct dcn_dccg *dccg_dcn = kzalloc_obj(*dccg_dcn);
struct dccg *base;
if (dccg_dcn == NULL) {
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
index b75bfea635fd..cf9c7a2089a1 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
@@ -542,7 +542,7 @@ void dal_hw_ddc_init_i3cpad(
*hw_ddc = NULL;
}
- *hw_ddc = kzalloc(sizeof(struct hw_ddc), GFP_KERNEL);
+ *hw_ddc = kzalloc_obj(struct hw_ddc);
if (!*hw_ddc) {
ASSERT_CRITICAL(false);
return;
diff --git a/drivers/gpu/drm/amd/display/dc/irq/dcn42/irq_service_dcn42.c b/drivers/gpu/drm/amd/display/dc/irq/dcn42/irq_service_dcn42.c
index f4d1ce9079de..3a87c1a26488 100644
--- a/drivers/gpu/drm/amd/display/dc/irq/dcn42/irq_service_dcn42.c
+++ b/drivers/gpu/drm/amd/display/dc/irq/dcn42/irq_service_dcn42.c
@@ -405,7 +405,7 @@ static void dcn42_irq_construct(struct irq_service *irq_service,
struct irq_service *dal_irq_service_dcn42_create(struct irq_service_init_data *init_data)
{
- struct irq_service *irq_service = kzalloc(sizeof(*irq_service), GFP_KERNEL);
+ struct irq_service *irq_service = kzalloc_obj(*irq_service);
if (!irq_service)
return NULL;
diff --git a/drivers/gpu/drm/amd/display/dc/irq/dcn60/irq_service_dcn60.c b/drivers/gpu/drm/amd/display/dc/irq/dcn60/irq_service_dcn60.c
index 99163346e7d9..651bae6b5ede 100644
--- a/drivers/gpu/drm/amd/display/dc/irq/dcn60/irq_service_dcn60.c
+++ b/drivers/gpu/drm/amd/display/dc/irq/dcn60/irq_service_dcn60.c
@@ -406,8 +406,7 @@ static void dcn60_irq_construct(
struct irq_service *dal_irq_service_dcn60_create(
struct irq_service_init_data *init_data)
{
- struct irq_service *irq_service = kzalloc(sizeof(*irq_service),
- GFP_KERNEL);
+ struct irq_service *irq_service = kzalloc_obj(*irq_service);
if (!irq_service)
return NULL;
diff --git a/drivers/gpu/drm/amd/display/dc/pg/dcn42/dcn42_pg_cntl.c b/drivers/gpu/drm/amd/display/dc/pg/dcn42/dcn42_pg_cntl.c
index 78b33b2dbae8..2c87e33e909e 100644
--- a/drivers/gpu/drm/amd/display/dc/pg/dcn42/dcn42_pg_cntl.c
+++ b/drivers/gpu/drm/amd/display/dc/pg/dcn42/dcn42_pg_cntl.c
@@ -615,7 +615,7 @@ struct pg_cntl *pg_cntl42_create(
const struct pg_cntl_shift *pg_cntl_shift,
const struct pg_cntl_mask *pg_cntl_mask)
{
- struct dcn_pg_cntl *pg_cntl_dcn = kzalloc(sizeof(*pg_cntl_dcn), GFP_KERNEL);
+ struct dcn_pg_cntl *pg_cntl_dcn = kzalloc_obj(*pg_cntl_dcn);
struct pg_cntl *base;
if (pg_cntl_dcn == NULL) {
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c
index dbb8bb7fc20d..aecbcd28c2d9 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c
@@ -1135,7 +1135,7 @@ static struct hpo_frl_stream_encoder *dcn30_hpo_frl_stream_encoder_create(enum e
}
/* allocate HPO stream encoder and create VPG sub-block */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn30_vpg_create(ctx, vpg_inst);
afmt = dcn30_afmt_create(ctx, afmt_inst);
@@ -1166,7 +1166,7 @@ static struct hpo_frl_link_encoder *dcn30_hpo_frl_link_encoder_create(enum engin
ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn302/dcn302_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn302/dcn302_resource.c
index 88dcf8166378..f67b3e00bd86 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn302/dcn302_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn302/dcn302_resource.c
@@ -492,7 +492,7 @@ static struct hpo_frl_stream_encoder *dcn302_hpo_frl_stream_encoder_create(enum
return NULL;
/* allocate HPO stream encoder and create VPG sub-block */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn302_vpg_create(ctx, vpg_inst);
afmt = dcn302_afmt_create(ctx, afmt_inst);
@@ -531,7 +531,7 @@ static struct hpo_frl_link_encoder *dcn302_hpo_frl_link_encoder_create(enum engi
ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn303/dcn303_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn303/dcn303_resource.c
index 50b7c7b85fac..9e1bf34cca2a 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn303/dcn303_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn303/dcn303_resource.c
@@ -479,7 +479,7 @@ static struct hpo_frl_stream_encoder *dcn303_hpo_frl_stream_encoder_create(enum
return NULL;
/* allocate HPO stream encoder and create VPG sub-block */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn303_vpg_create(ctx, vpg_inst);
afmt = dcn303_afmt_create(ctx, afmt_inst);
@@ -518,7 +518,7 @@ static struct hpo_frl_link_encoder *dcn303_hpo_frl_link_encoder_create(enum engi
ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c
index db56e30cf259..6359fbb574df 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c
@@ -1346,7 +1346,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e
}
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn31_vpg_create(ctx, vpg_inst);
afmt = dcn31_afmt_create(ctx, afmt_inst);
@@ -1377,7 +1377,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin
ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c
index 63f92e9da6d8..0ddfceca69dd 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c
@@ -1404,7 +1404,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e
}
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn31_vpg_create(ctx, vpg_inst);
afmt = dcn31_afmt_create(ctx, afmt_inst);
@@ -1436,7 +1436,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin
ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
index 15c1615c5f45..a1894be8cbb2 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
@@ -1347,7 +1347,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e
}
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn31_vpg_create(ctx, vpg_inst);
afmt = dcn31_afmt_create(ctx, afmt_inst);
@@ -1379,7 +1379,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin
ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn316/dcn316_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn316/dcn316_resource.c
index a5ea35e45791..4a2d56a196b4 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn316/dcn316_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn316/dcn316_resource.c
@@ -1340,7 +1340,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e
}
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn31_vpg_create(ctx, vpg_inst);
afmt = dcn31_afmt_create(ctx, afmt_inst);
@@ -1372,7 +1372,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin
ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
index 7c2a79015f4e..a2e66761b8ec 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
@@ -1339,7 +1339,7 @@ static struct hpo_frl_stream_encoder *dcn32_hpo_frl_stream_encoder_create(enum e
}
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn32_vpg_create(ctx, vpg_inst);
afmt = dcn32_afmt_create(ctx, afmt_inst);
@@ -1375,7 +1375,7 @@ static struct hpo_frl_link_encoder *dcn32_hpo_frl_link_encoder_create(enum engin
hpo_frl_link_encoder_reg_list(0);
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
index 5ee9a5a8ec3c..4097093d9012 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
@@ -1314,7 +1314,7 @@ static struct hpo_frl_stream_encoder *dcn321_hpo_frl_stream_encoder_create(enum
}
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn321_vpg_create(ctx, vpg_inst);
afmt = dcn321_afmt_create(ctx, afmt_inst);
@@ -1350,7 +1350,7 @@ static struct hpo_frl_link_encoder *dcn321_hpo_frl_link_encoder_create(enum engi
hpo_frl_link_encoder_reg_list(0);
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
index 52826e96c184..fd7a22fcca59 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
@@ -1398,7 +1398,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(
return NULL;
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn31_vpg_create(ctx, vpg_inst);
afmt = dcn31_afmt_create(ctx, afmt_inst);
@@ -1430,7 +1430,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(
hpo_frl_link_encoder_reg_list(0);
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c
index e3fc71307c91..83248ee01d11 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c
@@ -1378,7 +1378,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(
return NULL;
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn31_vpg_create(ctx, vpg_inst);
afmt = dcn31_afmt_create(ctx, afmt_inst);
@@ -1410,7 +1410,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(
hpo_frl_link_encoder_reg_list(0);
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn36/dcn36_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn36/dcn36_resource.c
index c019a657005d..8d1baa76c347 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn36/dcn36_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn36/dcn36_resource.c
@@ -1385,7 +1385,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(
return NULL;
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
vpg = dcn31_vpg_create(ctx, vpg_inst);
afmt = dcn31_afmt_create(ctx, afmt_inst);
@@ -1417,7 +1417,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(
hpo_frl_link_encoder_reg_list(0);
/* allocate HPO link encoder */
- hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_enc3)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c
index aced8ff657bf..0cfdca82bef0 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c
@@ -1322,7 +1322,7 @@ static struct hpo_frl_stream_encoder *dcn401_hpo_frl_stream_encoder_create(
return NULL;
/* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
- hpo_enc401 = kzalloc(sizeof(struct dcn401_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc401 = kzalloc_obj(struct dcn401_hpo_frl_stream_encoder);
vpg = dcn401_vpg_create(ctx, vpg_inst);
afmt = dcn401_afmt_create(ctx, afmt_inst);
@@ -1353,7 +1353,7 @@ static struct hpo_frl_link_encoder *dcn401_hpo_frl_link_encoder_create(
hpo_frl_link_encoder_reg_list(0);
/* allocate HPO link encoder */
- hpo_link_enc = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_link_enc = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_link_enc)
return NULL; /* out of memory */
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c
index b93d608b64a9..28192d6dda7a 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c
@@ -818,7 +818,7 @@ static struct dce_aux *dcn42_aux_engine_create(
uint32_t inst)
{
struct aux_engine_dce110 *aux_engine =
- kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL);
+ kzalloc_obj(struct aux_engine_dce110);
if (!aux_engine)
return NULL;
@@ -884,7 +884,7 @@ static struct dce_i2c_hw *dcn42_i2c_hw_create(
uint32_t inst)
{
struct dce_i2c_hw *dce_i2c_hw =
- kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL);
+ kzalloc_obj(struct dce_i2c_hw);
if (!dce_i2c_hw)
return NULL;
@@ -910,7 +910,7 @@ static struct clock_source *dcn42_clock_source_create(
bool dp_clk_src)
{
struct dce110_clk_src *clk_src =
- kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
+ kzalloc_obj(struct dce110_clk_src);
if (!clk_src)
return NULL;
@@ -929,8 +929,7 @@ static struct hubbub *dcn42_hubbub_create(struct dc_context *ctx)
{
int i;
- struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub),
- GFP_KERNEL);
+ struct dcn20_hubbub *hubbub3 = kzalloc_obj(struct dcn20_hubbub);
if (!hubbub3)
return NULL;
@@ -983,7 +982,7 @@ static struct hubp *dcn42_hubp_create(
uint32_t inst)
{
struct dcn20_hubp *hubp2 =
- kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_hubp);
if (!hubp2)
return NULL;
@@ -1025,7 +1024,7 @@ static struct dpp *dcn42_dpp_create(
uint32_t inst)
{
struct dcn42_dpp *dpp42 =
- kzalloc(sizeof(struct dcn42_dpp), GFP_KERNEL);
+ kzalloc_obj(struct dcn42_dpp);
if (!dpp42)
return NULL;
@@ -1051,8 +1050,7 @@ static struct mpc *dcn42_mpc_create(
int num_mpcc,
int num_rmu)
{
- struct dcn42_mpc *mpc401 = kzalloc(sizeof(struct dcn42_mpc),
- GFP_KERNEL);
+ struct dcn42_mpc *mpc401 = kzalloc_obj(struct dcn42_mpc);
if (!mpc401)
return NULL;
@@ -1075,7 +1073,7 @@ static struct output_pixel_processor *dcn42_opp_create(
struct dc_context *ctx, uint32_t inst)
{
struct dcn20_opp *opp4 =
- kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_opp);
if (!opp4) {
BREAK_TO_DEBUGGER();
@@ -1098,7 +1096,7 @@ static struct timing_generator *dcn42_timing_generator_create(
uint32_t instance)
{
struct optc *tgn10 =
- kzalloc(sizeof(struct optc), GFP_KERNEL);
+ kzalloc_obj(struct optc);
if (!tgn10)
return NULL;
@@ -1136,7 +1134,7 @@ static struct link_encoder *dcn42_link_encoder_create(
const struct encoder_init_data *enc_init_data)
{
struct dcn20_link_encoder *enc20 =
- kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_link_encoder);
if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
return NULL;
@@ -1202,7 +1200,7 @@ static struct vpg *dcn42_vpg_create(
struct dc_context *ctx,
uint32_t inst)
{
- struct dcn31_vpg *vpg4 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL);
+ struct dcn31_vpg *vpg4 = kzalloc_obj(struct dcn31_vpg);
if (!vpg4)
return NULL;
@@ -1231,7 +1229,7 @@ static struct apg *dcn42_apg_create(
struct dc_context *ctx,
uint32_t inst)
{
- struct dcn31_apg *apg31 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL);
+ struct dcn31_apg *apg31 = kzalloc_obj(struct dcn31_apg);
if (!apg31)
return NULL;
@@ -1275,7 +1273,7 @@ static struct stream_encoder *dcn42_stream_encoder_create(
} else
return NULL;
- enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
+ enc1 = kzalloc_obj(struct dcn10_stream_encoder);
vpg = dcn42_vpg_create(ctx, vpg_inst);
apg = dcn42_apg_create(ctx, apg_inst);
@@ -1325,7 +1323,7 @@ static struct hpo_frl_stream_encoder *dcn42_hpo_frl_stream_encoder_create(
return NULL;
/* allocate HPO stream encoder and create VPG sub-block */
- hpo_enc42 = kzalloc(sizeof(struct dcn42_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc42 = kzalloc_obj(struct dcn42_hpo_frl_stream_encoder);
vpg = dcn42_vpg_create(ctx, vpg_inst);
apg = dcn42_apg_create(ctx, apg_inst);
@@ -1357,7 +1355,7 @@ static struct hpo_frl_link_encoder *dcn42_hpo_frl_link_encoder_create(
hpo_frl_link_encoder_reg_list(0);
/* allocate HPO link encoder */
- hpo_link_enc = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_link_enc = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_link_enc)
return NULL; /* out of memory */
@@ -1399,7 +1397,7 @@ static struct hpo_dp_stream_encoder *dcn42_hpo_dp_stream_encoder_create(
apg_inst = hpo_dp_inst + 5;
/* allocate HPO stream encoder and create VPG sub-block */
- hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL);
+ hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_stream_encoder);
vpg = dcn42_vpg_create(ctx, vpg_inst);
apg = dcn42_apg_create(ctx, apg_inst);
@@ -1432,7 +1430,7 @@ static struct hpo_dp_link_encoder *dcn42_hpo_dp_link_encoder_create(
struct dcn31_hpo_dp_link_encoder *hpo_dp_enc31;
/* allocate HPO link encoder */
- hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
+ hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_link_encoder);
if (!hpo_dp_enc31)
return NULL; /* out of memory */
@@ -1453,7 +1451,7 @@ static struct hpo_dp_link_encoder *dcn42_hpo_dp_link_encoder_create(
static struct dce_hwseq *dcn42_hwseq_create(
struct dc_context *ctx)
{
- struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
+ struct dce_hwseq *hws = kzalloc_obj(struct dce_hwseq);
#undef REG_STRUCT
#define REG_STRUCT hwseq_reg
@@ -1727,8 +1725,7 @@ static bool dcn42_dwbc_create(struct dc_context *ctx, struct resource_pool *pool
uint32_t dwb_count = pool->res_cap->num_dwb;
for (i = 0; i < dwb_count; i++) {
- struct dcn30_dwbc *dwbc42 = kzalloc(sizeof(struct dcn30_dwbc),
- GFP_KERNEL);
+ struct dcn30_dwbc *dwbc42 = kzalloc_obj(struct dcn30_dwbc);
if (!dwbc42) {
dm_error("DC: failed to create dwbc42!\n");
@@ -1764,8 +1761,7 @@ static bool dcn42_mmhubbub_create(struct dc_context *ctx, struct resource_pool *
uint32_t pipe_count = pool->res_cap->num_dwb;
for (i = 0; i < pipe_count; i++) {
- struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub),
- GFP_KERNEL);
+ struct dcn30_mmhubbub *mcif_wb30 = kzalloc_obj(struct dcn30_mmhubbub);
if (!mcif_wb30) {
dm_error("DC: failed to create mcif_wb30!\n");
@@ -1793,7 +1789,7 @@ static struct display_stream_compressor *dcn42_dsc_create(
struct dc_context *ctx, uint32_t inst)
{
struct dcn401_dsc *dsc =
- kzalloc(sizeof(struct dcn401_dsc), GFP_KERNEL);
+ kzalloc_obj(struct dcn401_dsc);
if (!dsc) {
BREAK_TO_DEBUGGER();
@@ -1890,7 +1886,7 @@ static struct link_encoder *dcn42_link_enc_create_minimal(
if ((unsigned int)(eng_id - ENGINE_ID_DIGA) >= ctx->dc->res_pool->res_cap->num_dig_link_enc)
return NULL;
- enc20 = kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
+ enc20 = kzalloc_obj(struct dcn20_link_encoder);
if (!enc20)
return NULL;
@@ -2441,7 +2437,7 @@ struct resource_pool *dcn42_create_resource_pool(
struct dc *dc)
{
struct dcn42_resource_pool *pool =
- kzalloc(sizeof(struct dcn42_resource_pool), GFP_KERNEL);
+ kzalloc_obj(struct dcn42_resource_pool);
if (!pool)
return NULL;
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c
index 41f0c67f57ff..f36d0f828166 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c
@@ -870,7 +870,7 @@ static struct dce_aux *dcn42b_aux_engine_create(
uint32_t inst)
{
struct aux_engine_dce110 *aux_engine =
- kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL);
+ kzalloc_obj(struct aux_engine_dce110);
if (!aux_engine)
return NULL;
@@ -940,7 +940,7 @@ static struct dce_i2c_hw *dcn42b_i2c_hw_create(
uint32_t inst)
{
struct dce_i2c_hw *dce_i2c_hw =
- kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL);
+ kzalloc_obj(struct dce_i2c_hw);
if (!dce_i2c_hw)
return NULL;
@@ -968,7 +968,7 @@ static struct clock_source *dcn42b_clock_source_create(
bool dp_clk_src)
{
struct dce110_clk_src *clk_src =
- kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
+ kzalloc_obj(struct dce110_clk_src);
if (!clk_src)
return NULL;
@@ -988,8 +988,7 @@ static struct hubbub *dcn42b_hubbub_create(struct dc_context *ctx)
{
int i;
- struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub),
- GFP_KERNEL);
+ struct dcn20_hubbub *hubbub3 = kzalloc_obj(struct dcn20_hubbub);
if (!hubbub3)
return NULL;
@@ -1042,7 +1041,7 @@ static struct hubp *dcn42b_hubp_create(
uint32_t inst)
{
struct dcn20_hubp *hubp2 =
- kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_hubp);
if (!hubp2)
return NULL;
@@ -1084,7 +1083,7 @@ static struct dpp *dcn42b_dpp_create(
uint32_t inst)
{
struct dcn42_dpp *dpp42b =
- kzalloc(sizeof(struct dcn42_dpp), GFP_KERNEL);
+ kzalloc_obj(struct dcn42_dpp);
if (!dpp42b)
return NULL;
@@ -1110,8 +1109,7 @@ static struct mpc *dcn42b_mpc_create(
int num_mpcc,
int num_rmu)
{
- struct dcn42_mpc *mpc42b = kzalloc(sizeof(struct dcn42_mpc),
- GFP_KERNEL);
+ struct dcn42_mpc *mpc42b = kzalloc_obj(struct dcn42_mpc);
if (!mpc42b)
return NULL;
@@ -1134,7 +1132,7 @@ static struct output_pixel_processor *dcn42b_opp_create(
struct dc_context *ctx, uint32_t inst)
{
struct dcn20_opp *opp4 =
- kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_opp);
if (!opp4) {
BREAK_TO_DEBUGGER();
@@ -1158,7 +1156,7 @@ static struct timing_generator *dcn42b_timing_generator_create(
uint32_t instance)
{
struct optc *tgn10 =
- kzalloc(sizeof(struct optc), GFP_KERNEL);
+ kzalloc_obj(struct optc);
if (!tgn10)
return NULL;
@@ -1196,7 +1194,7 @@ static struct link_encoder *dcn42b_link_encoder_create(
const struct encoder_init_data *enc_init_data)
{
struct dcn20_link_encoder *enc20 =
- kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_link_encoder);
if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
return NULL;
@@ -1271,7 +1269,7 @@ static struct vpg *dcn42b_vpg_create(
struct dc_context *ctx,
uint32_t inst)
{
- struct dcn31_vpg *vpg4 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL);
+ struct dcn31_vpg *vpg4 = kzalloc_obj(struct dcn31_vpg);
if (!vpg4)
return NULL;
@@ -1300,7 +1298,7 @@ static struct apg *dcn42b_apg_create(
struct dc_context *ctx,
uint32_t inst)
{
- struct dcn31_apg *apg31 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL);
+ struct dcn31_apg *apg31 = kzalloc_obj(struct dcn31_apg);
if (!apg31)
return NULL;
@@ -1344,7 +1342,7 @@ static struct stream_encoder *dcn42b_stream_encoder_create(
} else
return NULL;
- enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
+ enc1 = kzalloc_obj(struct dcn10_stream_encoder);
vpg = dcn42b_vpg_create(ctx, vpg_inst);
apg = dcn42b_apg_create(ctx, apg_inst);
@@ -1404,7 +1402,7 @@ static struct hpo_dp_stream_encoder *dcn42b_hpo_dp_stream_encoder_create(
apg_inst = hpo_dp_inst + 6;
/* allocate HPO stream encoder and create VPG sub-block */
- hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL);
+ hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_stream_encoder);
vpg = dcn42b_vpg_create(ctx, vpg_inst);
apg = dcn42b_apg_create(ctx, apg_inst);
@@ -1437,7 +1435,7 @@ static struct hpo_dp_link_encoder *dcn42b_hpo_dp_link_encoder_create(
struct dcn31_hpo_dp_link_encoder *hpo_dp_enc31;
/* allocate HPO link encoder */
- hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
+ hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_link_encoder);
if (!hpo_dp_enc31)
return NULL; /* out of memory */
@@ -1457,7 +1455,7 @@ static struct hpo_dp_link_encoder *dcn42b_hpo_dp_link_encoder_create(
static struct dce_hwseq *dcn42b_hwseq_create(
struct dc_context *ctx)
{
- struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
+ struct dce_hwseq *hws = kzalloc_obj(struct dce_hwseq);
#undef REG_STRUCT
#define REG_STRUCT hwseq_reg
@@ -1716,8 +1714,7 @@ static bool dcn42b_dwbc_create(struct dc_context *ctx, struct resource_pool *poo
uint32_t dwb_count = pool->res_cap->num_dwb;
for (i = 0; i < dwb_count; i++) {
- struct dcn30_dwbc *dwbc42 = kzalloc(sizeof(struct dcn30_dwbc),
- GFP_KERNEL);
+ struct dcn30_dwbc *dwbc42 = kzalloc_obj(struct dcn30_dwbc);
if (!dwbc42) {
dm_error("DC: failed to create dwbc42!\n");
@@ -1753,8 +1750,7 @@ static bool dcn42b_mmhubbub_create(struct dc_context *ctx, struct resource_pool
uint32_t pipe_count = pool->res_cap->num_dwb;
for (i = 0; i < pipe_count; i++) {
- struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub),
- GFP_KERNEL);
+ struct dcn30_mmhubbub *mcif_wb30 = kzalloc_obj(struct dcn30_mmhubbub);
if (!mcif_wb30) {
dm_error("DC: failed to create mcif_wb30!\n");
@@ -1782,7 +1778,7 @@ static struct display_stream_compressor *dcn42b_dsc_create(
struct dc_context *ctx, uint32_t inst)
{
struct dcn401_dsc *dsc =
- kzalloc(sizeof(struct dcn401_dsc), GFP_KERNEL);
+ kzalloc_obj(struct dcn401_dsc);
if (!dsc) {
BREAK_TO_DEBUGGER();
@@ -1875,7 +1871,7 @@ static struct link_encoder *dcn42b_link_enc_create_minimal(
if ((unsigned int)(eng_id - ENGINE_ID_DIGA) >= ctx->dc->res_pool->res_cap->num_dig_link_enc)
return NULL;
- enc20 = kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
+ enc20 = kzalloc_obj(struct dcn20_link_encoder);
if (!enc20)
return NULL;
@@ -2439,7 +2435,7 @@ struct resource_pool *dcn42b_create_resource_pool(
struct dc *dc)
{
struct dcn42b_resource_pool *pool =
- kzalloc(sizeof(struct dcn42b_resource_pool), GFP_KERNEL);
+ kzalloc_obj(struct dcn42b_resource_pool);
if (!pool)
return NULL;
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn60/dcn60_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn60/dcn60_resource.c
index 4b7668abf4dc..d091ea55cb5d 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn60/dcn60_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn60/dcn60_resource.c
@@ -998,7 +998,7 @@ static struct dce_aux *dcn60_aux_engine_create(
uint32_t inst)
{
struct aux_engine_dce110 *aux_engine =
- kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL);
+ kzalloc_obj(struct aux_engine_dce110);
if (!aux_engine)
return NULL;
@@ -1037,7 +1037,7 @@ static struct dce_i2c_hw *dcn60_i2c_hw_create(
uint32_t inst)
{
struct dce_i2c_hw *dce_i2c_hw =
- kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL);
+ kzalloc_obj(struct dce_i2c_hw);
if (!dce_i2c_hw)
return NULL;
@@ -1061,7 +1061,7 @@ static struct clock_source *dcn60_clock_source_create(
bool dp_clk_src)
{
struct dce110_clk_src *clk_src =
- kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
+ kzalloc_obj(struct dce110_clk_src);
if (!clk_src)
return NULL;
@@ -1081,8 +1081,7 @@ static struct hubbub *dcn60_hubbub_create(struct dc_context *ctx)
{
int i;
- struct dcn20_hubbub *hubbub2 = kzalloc(sizeof(struct dcn20_hubbub),
- GFP_KERNEL);
+ struct dcn20_hubbub *hubbub2 = kzalloc_obj(struct dcn20_hubbub);
if (!hubbub2)
return NULL;
@@ -1136,7 +1135,7 @@ static struct hubp *dcn60_hubp_create(
uint32_t inst)
{
struct dcn20_hubp *hubp2 =
- kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_hubp);
if (!hubp2)
return NULL;
@@ -1168,7 +1167,7 @@ static struct dpp *dcn60_dpp_create(
uint32_t inst)
{
struct dcn60_dpp *dpp60 =
- kzalloc(sizeof(struct dcn60_dpp), GFP_KERNEL);
+ kzalloc_obj(struct dcn60_dpp);
if (!dpp60)
return NULL;
@@ -1194,8 +1193,7 @@ static struct mpc *dcn60_mpc_create(
int num_mpcc,
int num_rmu)
{
- struct dcn60_mpc *mpc60 = kzalloc(sizeof(struct dcn60_mpc),
- GFP_KERNEL);
+ struct dcn60_mpc *mpc60 = kzalloc_obj(struct dcn60_mpc);
if (!mpc60)
return NULL;
@@ -1218,7 +1216,7 @@ static struct output_pixel_processor *dcn60_opp_create(
struct dc_context *ctx, uint32_t inst)
{
struct dcn20_opp *opp2 =
- kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_opp);
if (!opp2) {
BREAK_TO_DEBUGGER();
@@ -1242,7 +1240,7 @@ static struct timing_generator *dcn60_timing_generator_create(
uint32_t instance)
{
struct optc *tgn10 =
- kzalloc(sizeof(struct optc), GFP_KERNEL);
+ kzalloc_obj(struct optc);
if (!tgn10)
return NULL;
@@ -1282,7 +1280,7 @@ static struct link_encoder *dcn60_link_encoder_create(
const struct encoder_init_data *enc_init_data)
{
struct dcn20_link_encoder *enc20 =
- kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_link_encoder);
if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) {
kfree(enc20);
@@ -1349,7 +1347,7 @@ static struct vpg *dcn60_vpg_create(
struct dc_context *ctx,
uint32_t inst)
{
- struct dcn31_vpg *vpg6 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL);
+ struct dcn31_vpg *vpg6 = kzalloc_obj(struct dcn31_vpg);
if (!vpg6)
return NULL;
@@ -1378,7 +1376,7 @@ static struct apg *dcn60_apg_create(
struct dc_context *ctx,
uint32_t inst)
{
- struct dcn31_apg *apg60 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL);
+ struct dcn31_apg *apg60 = kzalloc_obj(struct dcn31_apg);
if (!apg60)
return NULL;
@@ -1415,7 +1413,7 @@ static struct stream_encoder *dcn60_stream_encoder_create(
} else
return NULL;
- enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
+ enc1 = kzalloc_obj(struct dcn10_stream_encoder);
vpg = dcn60_vpg_create(ctx, vpg_inst);
apg = dcn60_apg_create(ctx, apg_inst);
@@ -1462,7 +1460,7 @@ static struct hpo_frl_stream_encoder *dcn60_hpo_frl_stream_encoder_create(
return NULL;
/* allocate HPO stream encoder and create VPG, APG sub-blocks */
- hpo_enc60 = kzalloc(sizeof(struct dcn401_hpo_frl_stream_encoder), GFP_KERNEL);
+ hpo_enc60 = kzalloc_obj(struct dcn401_hpo_frl_stream_encoder);
vpg = dcn60_vpg_create(ctx, vpg_inst);
apg = dcn60_apg_create(ctx, apg_inst);
@@ -1493,7 +1491,7 @@ static struct hpo_frl_link_encoder *dcn60_hpo_frl_link_encoder_create(
hpo_frl_link_encoder_reg_list(0);
/* allocate HPO link encoder */
- hpo_link_enc = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
+ hpo_link_enc = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
if (!hpo_link_enc)
return NULL; /* out of memory */
@@ -1535,7 +1533,7 @@ static struct hpo_dp_stream_encoder *dcn60_hpo_dp_stream_encoder_create(
apg_inst = hpo_dp_inst;
/* allocate HPO stream encoder and create VPG sub-block */
- hpo_dp_enc60 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL);
+ hpo_dp_enc60 = kzalloc_obj(struct dcn31_hpo_dp_stream_encoder);
vpg = dcn60_vpg_create(ctx, vpg_inst);
apg = dcn60_apg_create(ctx, apg_inst);
@@ -1568,7 +1566,7 @@ static struct hpo_dp_link_encoder *dcn60_hpo_dp_link_encoder_create(
struct dcn31_hpo_dp_link_encoder *hpo_dp_enc60;
/* allocate HPO link encoder */
- hpo_dp_enc60 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
+ hpo_dp_enc60 = kzalloc_obj(struct dcn31_hpo_dp_link_encoder);
if (!hpo_dp_enc60)
return NULL; /* out of memory */
@@ -1589,7 +1587,7 @@ static struct hpo_dp_link_encoder *dcn60_hpo_dp_link_encoder_create(
static struct dce_hwseq *dcn60_hwseq_create(
struct dc_context *ctx)
{
- struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
+ struct dce_hwseq *hws = kzalloc_obj(struct dce_hwseq);
#undef REG_STRUCT
#define REG_STRUCT hwseq_reg
@@ -1784,7 +1782,7 @@ static struct display_stream_compressor *dcn60_dsc_create(
struct dc_context *ctx, uint32_t inst)
{
struct dcn60_dsc *dsc =
- kzalloc(sizeof(struct dcn60_dsc), GFP_KERNEL);
+ kzalloc_obj(struct dcn60_dsc);
if (!dsc) {
BREAK_TO_DEBUGGER();
@@ -2363,7 +2361,7 @@ struct resource_pool *dcn60_create_resource_pool(
struct dc *dc)
{
struct dcn60_resource_pool *pool =
- kzalloc(sizeof(struct dcn60_resource_pool), GFP_KERNEL);
+ kzalloc_obj(struct dcn60_resource_pool);
if (!pool)
return NULL;
diff --git a/drivers/gpu/drm/amd/display/modules/power/power.c b/drivers/gpu/drm/amd/display/modules/power/power.c
index ee15c14a899e..2f9690e65ca9 100644
--- a/drivers/gpu/drm/amd/display/modules/power/power.c
+++ b/drivers/gpu/drm/amd/display/modules/power/power.c
@@ -111,7 +111,7 @@ struct mod_power *mod_power_create(struct dc *dc,
if (dc == NULL)
goto fail_dc_null;
- core_power = kzalloc(sizeof(struct core_power), GFP_KERNEL);
+ core_power = kzalloc_obj(struct core_power);
if (core_power == NULL)
goto fail_alloc_context;
@@ -129,8 +129,7 @@ struct mod_power *mod_power_create(struct dc *dc,
for (i = 0; i < MOD_POWER_MAX_CONCURRENT_STREAMS; i++) {
core_power->map[i].psr_context =
- kzalloc(sizeof(struct mod_power_psr_context),
- GFP_KERNEL);
+ kzalloc_obj(struct mod_power_psr_context);
if (core_power->map[i].psr_context == NULL)
goto fail_construct;
}
diff --git a/drivers/gpu/drm/amd/display/modules/power/power_abm.c b/drivers/gpu/drm/amd/display/modules/power/power_abm.c
index 5e86889eaa84..5f27dea4aa0a 100644
--- a/drivers/gpu/drm/amd/display/modules/power/power_abm.c
+++ b/drivers/gpu/drm/amd/display/modules/power/power_abm.c
@@ -705,8 +705,7 @@ void initialize_backlight_caps(struct core_power *core_power, unsigned int inst)
* (do not want to use 256 bytes on the stack)
*/
ext_backlight_caps = (struct dm_acpi_atif_backlight_caps *)
- (kzalloc(sizeof(struct dm_acpi_atif_backlight_caps),
- GFP_KERNEL));
+ (kzalloc_obj(struct dm_acpi_atif_backlight_caps));
if (ext_backlight_caps == NULL)
return;
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
index 2393fa8d4e4b..bdf1e489369e 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
@@ -2988,7 +2988,7 @@ static int smu7_init_voltage_dependency_on_display_clock_table(struct pp_hwmgr *
if (!amdgpu_device_ip_get_ip_block(hwmgr->adev, AMD_IP_BLOCK_TYPE_DCE))
return 0;
- table = kzalloc(struct_size(table, entries, 4), GFP_KERNEL);
+ table = kzalloc_flex(*table, entries, 4);
if (!table)
return -ENOMEM;
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c
index aa4daf8f7d6f..4f820db5f8dd 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c
@@ -222,7 +222,7 @@ static int smu_v15_0_8_tables_init(struct smu_context *smu)
smu_table->metrics_time = 0;
- driver_pptable = kzalloc(sizeof(PPTable_t), GFP_KERNEL);
+ driver_pptable = kzalloc_obj(PPTable_t);
if (!driver_pptable)
return -ENOMEM;
@@ -1026,7 +1026,7 @@ static int smu_v15_0_8_fru_get_product_info(struct smu_context *smu,
struct amdgpu_device *adev = smu->adev;
if (!adev->fru_info) {
- adev->fru_info = kzalloc(sizeof(*adev->fru_info), GFP_KERNEL);
+ adev->fru_info = kzalloc_obj(*adev->fru_info);
if (!adev->fru_info)
return -ENOMEM;
}
diff --git a/drivers/gpu/drm/amd/ras/core/cmd.c b/drivers/gpu/drm/amd/ras/core/cmd.c
index 6c37dc519eed..446b935c1fc9 100644
--- a/drivers/gpu/drm/amd/ras/core/cmd.c
+++ b/drivers/gpu/drm/amd/ras/core/cmd.c
@@ -222,7 +222,7 @@ static int ras_cmd_get_cper_records(struct ras_core_context *ras_core,
if (!buffer)
return RAS_CMD__ERROR_GENERIC;
- trace = kcalloc(trace_count, sizeof(*trace), GFP_KERNEL);
+ trace = kzalloc_objs(*trace, trace_count);
if (!trace) {
ret = RAS_CMD__ERROR_GENERIC;
goto out;
@@ -316,7 +316,7 @@ static int ras_cmd_get_batch_trace_records(struct ras_core_context *ras_core,
(input_data->start_batch_id >= overview.last_batch_id))
return RAS_CMD__ERROR_INVALID_INPUT_SIZE;
- trace_arry = kcalloc(trace_count, sizeof(*trace_arry), GFP_KERNEL);
+ trace_arry = kzalloc_objs(*trace_arry, trace_count);
if (!trace_arry)
return RAS_CMD__ERROR_GENERIC;
diff --git a/drivers/gpu/drm/drm_exec.c b/drivers/gpu/drm/drm_exec.c
index fa923852fae4..41034a5996ff 100644
--- a/drivers/gpu/drm/drm_exec.c
+++ b/drivers/gpu/drm/drm_exec.c
@@ -79,7 +79,7 @@ void drm_exec_init(struct drm_exec *exec, u32 flags, unsigned nr)
nr = PAGE_SIZE / sizeof(void *);
exec->flags = flags;
- exec->objects = kvmalloc_objs(*exec->objects, nr, GFP_KERNEL);
+ exec->objects = kvmalloc_objs(*exec->objects, nr);
/* If allocation here fails, just delay that till the first use */
exec->max_objects = exec->objects ? nr : 0;
diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 2fa170a29a62..c23a5de27eff 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -1619,7 +1619,7 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
goto err_points;
}
- chains = kmalloc_objs(*chains, args->count_handles, GFP_KERNEL);
+ chains = kmalloc_objs(*chains, args->count_handles);
if (!chains) {
ret = -ENOMEM;
goto err_points;
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 7f4178800afd..2fc41fb90aaa 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -981,7 +981,7 @@ static struct drm_plane *qxl_create_plane(struct qxl_device *qdev,
return ERR_PTR(-EINVAL);
}
- plane = kzalloc(sizeof(*plane), GFP_KERNEL);
+ plane = kzalloc_obj(*plane);
if (!plane)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c b/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c
index 2e7b3e87fea1..7583b6ebba2a 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c
@@ -22,7 +22,7 @@ tilcdc_panel_update_prop(struct of_changeset *ocs, struct device_node *node,
{
struct property *prop;
- prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+ prop = kzalloc_obj(*prop);
if (!prop)
return -ENOMEM;
diff --git a/drivers/gpu/drm/verisilicon/vs_plane.c b/drivers/gpu/drm/verisilicon/vs_plane.c
index d81f7b8f4c65..7ddb9d2dcb83 100644
--- a/drivers/gpu/drm/verisilicon/vs_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_plane.c
@@ -136,7 +136,7 @@ struct drm_plane_state *vs_plane_duplicate_state(struct drm_plane *plane)
vs_state_old = to_vs_plane_state(plane->state);
- vs_state = kzalloc_obj(*vs_state, GFP_KERNEL);
+ vs_state = kzalloc_obj(*vs_state);
if (!vs_state)
return NULL;
@@ -166,7 +166,7 @@ void vs_plane_reset(struct drm_plane *plane)
plane->state = NULL;
}
- vs_state = kzalloc_obj(*vs_state, GFP_KERNEL);
+ vs_state = kzalloc_obj(*vs_state);
if (!vs_state)
return;
diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
index 216c77cd0d21..149e6bcb5878 100644
--- a/drivers/gpu/drm/virtio/virtgpu_prime.c
+++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -293,9 +293,7 @@ int virtgpu_dma_buf_obj_resubmit(struct virtio_gpu_device *vgdev,
return -ENOMEM;
}
- ents = kvmalloc_array(bo->sgt->nents,
- sizeof(struct virtio_gpu_mem_entry),
- GFP_KERNEL);
+ ents = kvmalloc_objs(struct virtio_gpu_mem_entry, bo->sgt->nents);
if (!ents) {
DRM_ERROR("failed to allocate ent list\n");
return -ENOMEM;
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 7551b8c7766d..601e3f128c9f 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -212,7 +212,7 @@ static struct config_group *make_crtc_group(struct config_group *group,
if (dev->enabled)
return ERR_PTR(-EBUSY);
- crtc = kzalloc(sizeof(*crtc), GFP_KERNEL);
+ crtc = kzalloc_obj(*crtc);
if (!crtc)
return ERR_PTR(-ENOMEM);
@@ -368,7 +368,7 @@ static struct config_group *make_plane_group(struct config_group *group,
if (dev->enabled)
return ERR_PTR(-EBUSY);
- plane = kzalloc(sizeof(*plane), GFP_KERNEL);
+ plane = kzalloc_obj(*plane);
if (!plane)
return ERR_PTR(-ENOMEM);
@@ -484,7 +484,7 @@ static struct config_group *make_encoder_group(struct config_group *group,
if (dev->enabled)
return ERR_PTR(-EBUSY);
- encoder = kzalloc(sizeof(*encoder), GFP_KERNEL);
+ encoder = kzalloc_obj(*encoder);
if (!encoder)
return ERR_PTR(-ENOMEM);
@@ -651,7 +651,7 @@ static struct config_group *make_connector_group(struct config_group *group,
if (dev->enabled)
return ERR_PTR(-EBUSY);
- connector = kzalloc(sizeof(*connector), GFP_KERNEL);
+ connector = kzalloc_obj(*connector);
if (!connector)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpu/drm/xe/xe_amc.c b/drivers/gpu/drm/xe/xe_amc.c
index 8ecadee6eea3..edd50bf8261e 100644
--- a/drivers/gpu/drm/xe/xe_amc.c
+++ b/drivers/gpu/drm/xe/xe_amc.c
@@ -177,7 +177,7 @@ int xe_amc_init(struct xe_i2c *i2c)
{
struct xe_amc *amc;
- amc = kzalloc(sizeof(*amc), GFP_KERNEL);
+ amc = kzalloc_obj(*amc);
if (!amc)
return -ENOMEM;
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 9e0176861cb6..23952ad8951e 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -4148,7 +4148,7 @@ static int fill_faults(struct xe_vm *vm,
entry_size = sizeof(struct xe_vm_fault);
count = args->size / entry_size;
- fault_list = kcalloc(count, sizeof(struct xe_vm_fault), GFP_KERNEL);
+ fault_list = kzalloc_objs(struct xe_vm_fault, count);
if (!fault_list)
return -ENOMEM;
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index ec966fc0a411..c38a2b3b33d9 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -406,7 +406,7 @@ static int asus_kbd_fn_lock_set(struct asus_drvdata *drvdata, bool enabled)
struct asus_work_action *action;
unsigned long flags;
- action = kzalloc(sizeof(struct asus_work_action), GFP_ATOMIC);
+ action = kzalloc_obj(struct asus_work_action, GFP_ATOMIC);
if (!action)
return -ENOMEM;
@@ -433,7 +433,7 @@ static int asus_kbd_wmi_fan_send(struct asus_drvdata *drvdata, u8 *report_data,
return -EINVAL;
}
- action = kzalloc(sizeof(struct asus_work_action), GFP_NOWAIT);
+ action = kzalloc_obj(struct asus_work_action, GFP_NOWAIT);
if (!action)
return -ENOMEM;
@@ -746,7 +746,7 @@ static void asus_kbd_backlight_set(struct asus_hid_listener *listener, int brigh
drvdata->kbd_backlight_brightness = brightness;
- action = kzalloc(sizeof(struct asus_work_action), GFP_NOWAIT);
+ action = kzalloc_obj(struct asus_work_action, GFP_NOWAIT);
if (!action)
return;
diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
index ac08cb2d0368..0f364d43aa4b 100644
--- a/drivers/hid/hid-steam.c
+++ b/drivers/hid/hid-steam.c
@@ -759,7 +759,7 @@ static inline int steam_haptic_pulse(struct steam_device *steam, u8 pad,
if (steam->quirks & STEAM_QUIRK_IBEX) {
struct steam_ibex_output_report *report =
- kzalloc(sizeof(struct steam_ibex_output_report), GFP_KERNEL);
+ kzalloc_obj(struct steam_ibex_output_report);
if (!report)
return -ENOMEM;
@@ -798,7 +798,7 @@ static inline int steam_haptic_rumble(struct steam_device *steam,
if (steam->quirks & STEAM_QUIRK_IBEX) {
struct steam_ibex_output_report *report =
- kzalloc(sizeof(struct steam_ibex_output_report), GFP_KERNEL);
+ kzalloc_obj(struct steam_ibex_output_report);
if (!report)
return -ENOMEM;
diff --git a/drivers/hid/hid-steelseries-arctis.c b/drivers/hid/hid-steelseries-arctis.c
index 23fb0cebd72a..7a855b66730a 100644
--- a/drivers/hid/hid-steelseries-arctis.c
+++ b/drivers/hid/hid-steelseries-arctis.c
@@ -469,7 +469,7 @@ static int steelseries_arctis_probe(struct hid_device *hdev,
return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
if (interface_num == info->sync_interface) {
- sd = kzalloc_obj(*sd, GFP_KERNEL);
+ sd = kzalloc_obj(*sd);
if (!sd)
return -ENOMEM;
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index f4370617deac..7e4cc6f55237 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -694,12 +694,11 @@ void *vmbus_alloc_buffer(struct vmbus_channel *channel,
return vzalloc(nr_pages << PAGE_SHIFT);
/* Worst case: every chunk is a single page. */
- chunks = kvmalloc_array(nr_pages, sizeof(*chunks),
- GFP_KERNEL | __GFP_ZERO);
+ chunks = kvmalloc_objs(*chunks, nr_pages, GFP_KERNEL | __GFP_ZERO);
if (!chunks)
goto err;
- pages = kvmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL);
+ pages = kvmalloc_objs(*pages, nr_pages);
if (!pages)
goto err;
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 9cba97e81111..39c1b793a893 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -939,7 +939,7 @@ static unsigned long process_hot_add(unsigned long pg_start,
*/
if (rg_size != 0) {
- ha_region = kzalloc(sizeof(struct hv_hotadd_state), GFP_KERNEL);
+ ha_region = kzalloc_obj(struct hv_hotadd_state);
if (!ha_region)
return 0;
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index ca56bd8b170e..00e603b5e401 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1476,9 +1476,9 @@ static int __init applesmc_init(void)
applesmc_fan_config[smcreg.fan_count] = 0;
applesmc_pwm_config[smcreg.fan_count] = 0;
- applesmc_info_temp = kzalloc_obj(*applesmc_info_temp, GFP_KERNEL);
- applesmc_info_fan = kzalloc_obj(*applesmc_info_fan, GFP_KERNEL);
- applesmc_info_pwm = kzalloc_obj(*applesmc_info_pwm, GFP_KERNEL);
+ applesmc_info_temp = kzalloc_obj(*applesmc_info_temp);
+ applesmc_info_fan = kzalloc_obj(*applesmc_info_fan);
+ applesmc_info_pwm = kzalloc_obj(*applesmc_info_pwm);
if (!applesmc_info_temp || !applesmc_info_fan || !applesmc_info_pwm) {
ret = -ENOMEM;
goto out_info;
@@ -1493,7 +1493,7 @@ static int __init applesmc_init(void)
applesmc_info_pwm->type = hwmon_pwm;
applesmc_info_pwm->config = applesmc_pwm_config;
- applesmc_info_arr = kcalloc(4, sizeof(*applesmc_info_arr), GFP_KERNEL);
+ applesmc_info_arr = kzalloc_objs(*applesmc_info_arr, 4);
if (!applesmc_info_arr) {
ret = -ENOMEM;
goto out_info;
@@ -1504,7 +1504,7 @@ static int __init applesmc_init(void)
applesmc_info_arr[2] = applesmc_info_pwm;
applesmc_info_arr[3] = NULL;
- applesmc_chip = kzalloc_obj(*applesmc_chip, GFP_KERNEL);
+ applesmc_chip = kzalloc_obj(*applesmc_chip);
if (!applesmc_chip) {
ret = -ENOMEM;
goto out_info;
@@ -1514,10 +1514,9 @@ static int __init applesmc_init(void)
applesmc_chip->info = applesmc_info_arr;
/* Create non-standard fanX_safe attributes group */
- fan_safe_attrs = kcalloc(smcreg.fan_count,
- sizeof(*fan_safe_attrs), GFP_KERNEL);
- fan_safe_attr_list = kcalloc(smcreg.fan_count + 1,
- sizeof(*fan_safe_attr_list), GFP_KERNEL);
+ fan_safe_attrs = kzalloc_objs(*fan_safe_attrs, smcreg.fan_count);
+ fan_safe_attr_list = kzalloc_objs(*fan_safe_attr_list,
+ smcreg.fan_count + 1);
if (!fan_safe_attrs || !fan_safe_attr_list) {
ret = -ENOMEM;
goto out_info;
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index 6d65c43d574f..928488a216d4 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1679,7 +1679,7 @@ coresight_allocate_device_list(const char *prefix)
return list;
}
- list = kzalloc(sizeof(*list), GFP_KERNEL);
+ list = kzalloc_obj(*list);
if (!list)
return NULL;
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index b7521b7ece37..6294b0b0cc8f 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -418,7 +418,7 @@ static struct i2c_gpio_scl_data *i2c_gpio_create_scl(struct device *dev)
}
}
- scl = kzalloc(sizeof(*scl), GFP_KERNEL);
+ scl = kzalloc_obj(*scl);
if (!scl) {
if (sharable)
fwnode_handle_put(args.fwnode);
diff --git a/drivers/i3c/master/amd-i3c-master.c b/drivers/i3c/master/amd-i3c-master.c
index ef5ad5abb788..e4da9c38eccb 100644
--- a/drivers/i3c/master/amd-i3c-master.c
+++ b/drivers/i3c/master/amd-i3c-master.c
@@ -376,7 +376,7 @@ static struct xi3c_xfer *xi3c_master_alloc_xfer(unsigned int ncmds)
{
struct xi3c_xfer *xfer;
- xfer = kzalloc_flex(*xfer, cmds, ncmds, GFP_KERNEL);
+ xfer = kzalloc_flex(*xfer, cmds, ncmds);
if (!xfer)
return NULL;
@@ -735,7 +735,7 @@ static int xi3c_master_send_bdcast_ccc_cmd(struct xi3c_master *master,
if (!xfer)
return -ENOMEM;
- buf = kmalloc_objs(*buf, xfer_len, GFP_KERNEL);
+ buf = kmalloc_objs(*buf, xfer_len);
if (!buf)
return -ENOMEM;
diff --git a/drivers/iio/adc/ad7280a.c b/drivers/iio/adc/ad7280a.c
index 505fa68ee539..5ae0d694d20c 100644
--- a/drivers/iio/adc/ad7280a.c
+++ b/drivers/iio/adc/ad7280a.c
@@ -796,8 +796,8 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
struct ad7280_state *st = iio_priv(indio_dev);
int i, ret;
- unsigned int *channels __free(kfree) = kcalloc(st->scan_cnt, sizeof(*channels),
- GFP_KERNEL);
+ unsigned int *channels __free(kfree) = kzalloc_objs(*channels,
+ st->scan_cnt);
if (!channels)
return IRQ_HANDLED;
diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
index ecc02a427b92..1bd82d3db5ea 100644
--- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c
+++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
@@ -109,7 +109,7 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue,
if (nents < 0)
return nents;
- vecs = kmalloc_array(nents, sizeof(*vecs), GFP_ATOMIC);
+ vecs = kmalloc_objs(*vecs, nents, GFP_ATOMIC);
if (!vecs)
return -ENOMEM;
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index fb08e4f02520..1f22275de55c 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -345,7 +345,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
return ERR_PTR(-ENODEV);
struct iio_channel *channel __free(kfree) =
- kzalloc(sizeof(*channel), GFP_KERNEL);
+ kzalloc_obj(*channel);
if (!channel) {
err = -ENOMEM;
goto error_no_mem;
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index a4014a230639..4e8fbee34745 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -2943,7 +2943,7 @@ static int nldev_frmr_pools_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
u32 aging_period;
int err;
- tb = kzalloc_objs(*tb, RDMA_NLDEV_ATTR_MAX, GFP_KERNEL);
+ tb = kzalloc_objs(*tb, RDMA_NLDEV_ATTR_MAX);
if (!tb)
return -ENOMEM;
diff --git a/drivers/infiniband/hw/hns/hns_roce_debugfs.c b/drivers/infiniband/hw/hns/hns_roce_debugfs.c
index 05630f7c9155..103b8c9ca969 100644
--- a/drivers/infiniband/hw/hns/hns_roce_debugfs.c
+++ b/drivers/infiniband/hw/hns/hns_roce_debugfs.c
@@ -267,8 +267,7 @@ static int hns_roce_alloc_scc_param(struct hns_roce_dev *hr_dev)
struct hns_roce_scc_param *scc_param;
int i;
- scc_param = kvcalloc(HNS_ROCE_SCC_ALGO_TOTAL, sizeof(*scc_param),
- GFP_KERNEL);
+ scc_param = kvzalloc_objs(*scc_param, HNS_ROCE_SCC_ALGO_TOTAL);
if (!scc_param)
return -ENOMEM;
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 78c10eea7328..01c91fec9b7e 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -2344,7 +2344,7 @@ static int input_device_tune_vals(struct input_dev *dev)
if (dev->max_vals >= max_vals)
return 0;
- vals = kcalloc(max_vals, sizeof(*vals), GFP_KERNEL);
+ vals = kzalloc_objs(*vals, max_vals);
if (!vals)
return -ENOMEM;
diff --git a/drivers/input/keyboard/adp5585-keys.c b/drivers/input/keyboard/adp5585-keys.c
index 017c95029180..f2c1ba017d20 100644
--- a/drivers/input/keyboard/adp5585-keys.c
+++ b/drivers/input/keyboard/adp5585-keys.c
@@ -115,8 +115,8 @@ static int adp5585_keys_parse_fw(const struct adp5585_dev *adp5585,
"Too many keypad pins (%d) defined (max=%d)\n",
n_pins, adp5585->n_pins);
- unsigned int *keypad_pins __free(kfree) = kcalloc(n_pins, sizeof(*keypad_pins),
- GFP_KERNEL);
+ unsigned int *keypad_pins __free(kfree) = kzalloc_objs(*keypad_pins,
+ n_pins);
if (!keypad_pins)
return -ENOMEM;
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 5736f4bc5a50..b9ad2381f885 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -1070,7 +1070,7 @@ static int atkbd_get_keymap_from_fwnode(struct atkbd *atkbd)
if (n <= 0 || n > ATKBD_KEYMAP_SIZE)
return -ENXIO;
- u32 *ptr __free(kfree) = kcalloc(n, sizeof(*ptr), GFP_KERNEL);
+ u32 *ptr __free(kfree) = kzalloc_objs(*ptr, n);
if (!ptr)
return -ENOMEM;
diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
index b1a0edcc49b4..c3244c1a3751 100644
--- a/drivers/input/misc/ims-pcu.c
+++ b/drivers/input/misc/ims-pcu.c
@@ -1844,7 +1844,7 @@ static int ims_pcu_line_setup(struct ims_pcu *pcu)
{
struct usb_host_interface *interface = pcu->ctrl_intf->cur_altsetting;
struct usb_cdc_line_coding *line __free(kfree) =
- kmalloc(sizeof(*line), GFP_KERNEL);
+ kmalloc_obj(*line);
int error;
if (!line)
diff --git a/drivers/input/mouse/psmouse-smbus.c b/drivers/input/mouse/psmouse-smbus.c
index 7fb4cbb2aca2..98d9c860d2db 100644
--- a/drivers/input/mouse/psmouse-smbus.c
+++ b/drivers/input/mouse/psmouse-smbus.c
@@ -232,7 +232,7 @@ int psmouse_smbus_init(struct psmouse *psmouse,
struct psmouse_smbus_dev *smbdev;
int error;
- smbdev = kzalloc(sizeof(*smbdev), GFP_KERNEL);
+ smbdev = kzalloc_obj(*smbdev);
if (!smbdev)
return -ENOMEM;
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index a7ccedfa459c..868dee9a2ed8 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -84,7 +84,7 @@ static int serio_raw_open(struct inode *inode, struct file *file)
if (serio_raw->dead)
return -ENODEV;
- client = kzalloc(sizeof(*client), GFP_KERNEL);
+ client = kzalloc_obj(*client);
if (!client)
return -ENOMEM;
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
index 50f8321e979c..dd2fee2f560e 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
@@ -796,7 +796,7 @@ static inline struct arm_smmu_invs *arm_smmu_invs_alloc(size_t num_invs)
{
struct arm_smmu_invs *new_invs;
- new_invs = kzalloc(struct_size(new_invs, inv, num_invs), GFP_KERNEL);
+ new_invs = kzalloc_flex(*new_invs, inv, num_invs);
if (!new_invs)
return NULL;
new_invs->max_invs = num_invs;
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 5c4b06eda546..a664c70a6fe7 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -76,7 +76,7 @@ static struct iommufd_group *iommufd_alloc_group(struct iommufd_ctx *ictx,
{
struct iommufd_group *new_igroup;
- new_igroup = kzalloc_obj(*new_igroup, GFP_KERNEL);
+ new_igroup = kzalloc_obj(*new_igroup);
if (!new_igroup)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/iommu/iommufd/driver.c b/drivers/iommu/iommufd/driver.c
index 3b8067976eac..e4d17a748178 100644
--- a/drivers/iommu/iommufd/driver.c
+++ b/drivers/iommu/iommufd/driver.c
@@ -49,7 +49,7 @@ int _iommufd_alloc_mmap(struct iommufd_ctx *ictx, struct iommufd_object *owner,
if (!length || !PAGE_ALIGNED(length))
return -EINVAL;
- immap = kzalloc(sizeof(*immap), GFP_KERNEL);
+ immap = kzalloc_obj(*immap);
if (!immap)
return -ENOMEM;
immap->owner = owner;
diff --git a/drivers/iommu/iommufd/hwpt_noiommu.c b/drivers/iommu/iommufd/hwpt_noiommu.c
index 9b8b5eb71491..a80209a7429a 100644
--- a/drivers/iommu/iommufd/hwpt_noiommu.c
+++ b/drivers/iommu/iommufd/hwpt_noiommu.c
@@ -54,7 +54,7 @@ noiommu_alloc_paging_flags(struct device *dev, u32 flags,
(BIT(PT_FEAT_DYNAMIC_TOP) | BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) |
BIT(PT_FEAT_AMDV1_FORCE_COHERENCE));
- dom = kzalloc(sizeof(*dom), GFP_KERNEL);
+ dom = kzalloc_obj(*dom);
if (!dom)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 42c424496d07..5dac20b143a5 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -231,7 +231,7 @@ static struct iommu_domain *vsi_iommu_domain_alloc_paging(struct device *dev)
struct vsi_iommu *iommu = dev_iommu_priv_get(dev);
struct vsi_iommu_domain *vsi_domain;
- vsi_domain = kzalloc(sizeof(*vsi_domain), GFP_KERNEL);
+ vsi_domain = kzalloc_obj(*vsi_domain);
if (!vsi_domain)
return NULL;
diff --git a/drivers/irqchip/irq-gic-v5-irs.c b/drivers/irqchip/irq-gic-v5-irs.c
index b3feb6340b59..4486645a4b6f 100644
--- a/drivers/irqchip/irq-gic-v5-irs.c
+++ b/drivers/irqchip/irq-gic-v5-irs.c
@@ -618,7 +618,7 @@ static int __init gicv5_irs_of_init_affinity(struct device_node *node,
if (niaffids != ncpus)
return -EINVAL;
- u16 *iaffids __free(kfree) = kcalloc(niaffids, sizeof(*iaffids), GFP_KERNEL);
+ u16 *iaffids __free(kfree) = kzalloc_objs(*iaffids, niaffids);
if (!iaffids)
return -ENOMEM;
diff --git a/drivers/irqchip/irq-loongarch-ir.c b/drivers/irqchip/irq-loongarch-ir.c
index 21c649a89a70..cb4ad34da058 100644
--- a/drivers/irqchip/irq-loongarch-ir.c
+++ b/drivers/irqchip/irq-loongarch-ir.c
@@ -331,7 +331,7 @@ static int redirect_domain_alloc(struct irq_domain *domain, unsigned int virq,
struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq + i);
struct redirect_item *item;
- item = kzalloc(sizeof(*item), GFP_KERNEL);
+ item = kzalloc_obj(*item);
if (!item) {
pr_err("Alloc redirect descriptor failed\n");
goto out_free_resources;
diff --git a/drivers/irqchip/irq-realtek-rtl.c b/drivers/irqchip/irq-realtek-rtl.c
index 26e52c3f8c68..f1ab5a77dcef 100644
--- a/drivers/irqchip/irq-realtek-rtl.c
+++ b/drivers/irqchip/irq-realtek-rtl.c
@@ -188,7 +188,7 @@ static int __init realtek_setup_parents(struct device_node *node)
struct irq_domain *domain;
cnt = max(1, num_parents);
- output = kcalloc(cnt, sizeof(*output), GFP_KERNEL);
+ output = kzalloc_objs(*output, cnt);
if (!output)
return -ENOMEM;
diff --git a/drivers/mailbox/riscv-sbi-mpxy-mbox.c b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
index 714f7fb97a2f..ea69c6b6b4f9 100644
--- a/drivers/mailbox/riscv-sbi-mpxy-mbox.c
+++ b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
@@ -783,7 +783,7 @@ static int mpxy_mbox_populate_channels(struct mpxy_mbox *mbox)
return dev_err_probe(mbox->dev, -ENODEV, "no MPXY channels available\n");
/* Allocate and fetch all channel IDs */
- channel_ids = kcalloc(mbox->channel_count, sizeof(*channel_ids), GFP_KERNEL);
+ channel_ids = kzalloc_objs(*channel_ids, mbox->channel_count);
if (!channel_ids)
return -ENOMEM;
rc = mpxy_get_channel_ids(mbox->channel_count, channel_ids);
diff --git a/drivers/md/dm-inlinecrypt.c b/drivers/md/dm-inlinecrypt.c
index 66fa2f9d1fdc..3479dfe5f708 100644
--- a/drivers/md/dm-inlinecrypt.c
+++ b/drivers/md/dm-inlinecrypt.c
@@ -322,7 +322,7 @@ static int inlinecrypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
return -EINVAL;
}
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx);
if (!ctx) {
ti->error = "Out of memory";
return -ENOMEM;
diff --git a/drivers/md/md-llbitmap.c b/drivers/md/md-llbitmap.c
index e1a783ee2032..1c9fcc746ec6 100644
--- a/drivers/md/md-llbitmap.c
+++ b/drivers/md/md-llbitmap.c
@@ -810,7 +810,7 @@ static int llbitmap_expand_pages(struct llbitmap *llbitmap,
if (nr_pages <= old_nr_pages)
return 0;
- pctl = kcalloc(nr_pages, sizeof(*pctl), GFP_NOIO);
+ pctl = kzalloc_objs(*pctl, nr_pages, GFP_NOIO);
if (!pctl)
return -ENOMEM;
@@ -846,7 +846,7 @@ static int llbitmap_alloc_pages(struct llbitmap *llbitmap)
unsigned int nr_pages = max(used_pages, llbitmap_reserved_pages(llbitmap));
int i;
- llbitmap->pctl = kcalloc(nr_pages, sizeof(*llbitmap->pctl), GFP_NOIO);
+ llbitmap->pctl = kzalloc_objs(*llbitmap->pctl, nr_pages, GFP_NOIO);
if (!llbitmap->pctl)
return -ENOMEM;
diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
index eac3bc9af990..4f3299a66b37 100644
--- a/drivers/media/platform/allegro-dvt/allegro-core.c
+++ b/drivers/media/platform/allegro-dvt/allegro-core.c
@@ -3105,7 +3105,7 @@ static int allegro_open(struct file *file)
unsigned int cpb_size_max;
unsigned int cpb_size_def;
- channel = kzalloc(sizeof(*channel), GFP_KERNEL);
+ channel = kzalloc_obj(*channel);
if (!channel)
return -ENOMEM;
diff --git a/drivers/media/platform/amd/isp4/isp4_interface.c b/drivers/media/platform/amd/isp4/isp4_interface.c
index 4801617f9559..218aad5d7dfb 100644
--- a/drivers/media/platform/amd/isp4/isp4_interface.c
+++ b/drivers/media/platform/amd/isp4/isp4_interface.c
@@ -127,7 +127,7 @@ isp4if_gpu_mem_alloc(struct isp4_interface *ispif, u32 mem_size)
struct device *dev = ispif->dev;
int ret;
- mem_info = kmalloc_obj(*mem_info, GFP_KERNEL);
+ mem_info = kmalloc_obj(*mem_info);
if (!mem_info)
return NULL;
@@ -368,7 +368,7 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id,
/* Allocate the sync command object early and outside of the lock */
if (sync) {
- ele = kmalloc_obj(*ele, GFP_KERNEL);
+ ele = kmalloc_obj(*ele);
if (!ele)
return -ENOMEM;
@@ -738,7 +738,7 @@ isp4if_alloc_buffer_node(struct isp4if_img_buf_info *buf_info)
{
struct isp4if_img_buf_node *node;
- node = kmalloc_obj(*node, GFP_KERNEL);
+ node = kmalloc_obj(*node);
if (node)
node->buf_info = *buf_info;
diff --git a/drivers/media/platform/renesas/rcar-isp/core.c b/drivers/media/platform/renesas/rcar-isp/core.c
index b5861d0cd0e8..586a5adbedfa 100644
--- a/drivers/media/platform/renesas/rcar-isp/core.c
+++ b/drivers/media/platform/renesas/rcar-isp/core.c
@@ -232,7 +232,7 @@ int risp_core_job_prepare(struct rcar_isp_core *core)
}
/* Memory is released when the job is consumed. */
- job = kzalloc(sizeof(*job), GFP_KERNEL);
+ job = kzalloc_obj(*job);
if (!job)
return -ENOMEM;
diff --git a/drivers/media/rc/igorplugusb.c b/drivers/media/rc/igorplugusb.c
index b5117ee9f5fa..7758487da3d3 100644
--- a/drivers/media/rc/igorplugusb.c
+++ b/drivers/media/rc/igorplugusb.c
@@ -164,7 +164,7 @@ static int igorplugusb_probe(struct usb_interface *intf,
if (!ir)
return -ENOMEM;
- ir->request = kzalloc_obj(*ir->request, GFP_KERNEL);
+ ir->request = kzalloc_obj(*ir->request);
if (!ir->request)
goto fail;
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 7aa32b90cf1e..16ad4fd26357 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -135,7 +135,7 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev,
return -EAGAIN;
allocate_of_node:
- of_entry = kzalloc(sizeof(*of_entry), GFP_KERNEL);
+ of_entry = kzalloc_obj(*of_entry);
if (!of_entry)
return -ENOMEM;
@@ -174,7 +174,7 @@ static int mfd_add_device(struct device *parent, int id,
if (!pdev->mfd_cell)
goto fail_device;
- res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL);
+ res = kzalloc_objs(*res, cell->num_resources);
if (!res)
goto fail_device;
diff --git a/drivers/mfd/ucb1x00-assabet.c b/drivers/mfd/ucb1x00-assabet.c
index ee49ac779d1a..698f60aa9756 100644
--- a/drivers/mfd/ucb1x00-assabet.c
+++ b/drivers/mfd/ucb1x00-assabet.c
@@ -96,7 +96,7 @@ static int ucb1x00_assabet_add(struct ucb1x00_dev *dev)
struct ucb1x00_assabet_priv *priv;
- priv = kzalloc_obj(*priv, GFP_KERNEL);
+ priv = kzalloc_obj(*priv);
if (!priv)
return -ENOMEM;
diff --git a/drivers/mtd/mtd_virt_concat.c b/drivers/mtd/mtd_virt_concat.c
index da4277ced4d6..25cf33fe1ec1 100644
--- a/drivers/mtd/mtd_virt_concat.c
+++ b/drivers/mtd/mtd_virt_concat.c
@@ -166,7 +166,7 @@ static int mtd_virt_concat_create_item(struct device_node *parts,
return 0;
}
- item = kzalloc_flex(*item, nodes, count, GFP_KERNEL);
+ item = kzalloc_flex(*item, nodes, count);
if (!item)
return -ENOMEM;
@@ -182,7 +182,7 @@ static int mtd_virt_concat_create_item(struct device_node *parts,
for (i = 1; i < count; i++)
item->nodes[i] = of_parse_phandle(parts, CONCAT_PROP, (i - 1));
- concat = kzalloc_flex(*concat, subdev, count, GFP_KERNEL);
+ concat = kzalloc_flex(*concat, subdev, count);
if (!concat) {
kfree(item);
return -ENOMEM;
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index c97167d51fe2..d54d309c30a0 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -639,7 +639,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
printk(KERN_NOTICE "into device \"%s\"\n", name);
/* allocate the device structure */
- concat = kzalloc_flex(*concat, subdev, num_devs, GFP_KERNEL);
+ concat = kzalloc_flex(*concat, subdev, num_devs);
if (!concat) {
printk
("memory allocation error while creating concatenated device \"%s\"\n",
diff --git a/drivers/net/dsa/mv88e6xxx/tcflower.c b/drivers/net/dsa/mv88e6xxx/tcflower.c
index d67604a55b9f..2ddfeaaa0690 100644
--- a/drivers/net/dsa/mv88e6xxx/tcflower.c
+++ b/drivers/net/dsa/mv88e6xxx/tcflower.c
@@ -97,7 +97,7 @@ int mv88e6xxx_cls_flower_add(struct dsa_switch *ds, int port,
goto err_unlock;
}
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry) {
err = -ENOMEM;
goto err_unlock;
diff --git a/drivers/net/ethernet/alibaba/eea/eea_adminq.c b/drivers/net/ethernet/alibaba/eea/eea_adminq.c
index dfad1bdbc44d..73d0caf25700 100644
--- a/drivers/net/ethernet/alibaba/eea/eea_adminq.c
+++ b/drivers/net/ethernet/alibaba/eea/eea_adminq.c
@@ -439,8 +439,7 @@ int eea_adminq_dev_status(struct eea_net *enet,
q_num = enet->cfg.rx_ring_num + enet->cfg.tx_ring_num + 1;
io_num = enet->cfg.rx_ring_num + enet->cfg.tx_ring_num;
- req = kcalloc(q_num, sizeof(struct eea_aq_queue_drv_status),
- GFP_KERNEL);
+ req = kzalloc_objs(struct eea_aq_queue_drv_status, q_num);
if (!req)
return -ENOMEM;
@@ -486,11 +485,11 @@ void eea_adminq_config_host_info(struct eea_net *enet)
struct eea_aq_host_info_rep *rep;
int rc = -ENOMEM;
- cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ cfg = kzalloc_obj(*cfg);
if (!cfg)
return;
- rep = kzalloc(sizeof(*rep), GFP_KERNEL);
+ rep = kzalloc_obj(*rep);
if (!rep)
goto err_free_cfg;
diff --git a/drivers/net/ethernet/alibaba/eea/eea_net.c b/drivers/net/ethernet/alibaba/eea/eea_net.c
index 63e68580de94..0af6c95b5e63 100644
--- a/drivers/net/ethernet/alibaba/eea/eea_net.c
+++ b/drivers/net/ethernet/alibaba/eea/eea_net.c
@@ -62,7 +62,7 @@ static int eea_alloc_irq_blks(struct eea_net *enet)
num = enet->edev->rx_num;
- irq_blks = kvcalloc(num, sizeof(*blk), GFP_KERNEL);
+ irq_blks = kvzalloc_objs(*blk, num);
if (!irq_blks)
return -ENOMEM;
@@ -194,11 +194,11 @@ static int eea_alloc_rxtx_q_mem(struct eea_net_init_ctx *ctx)
struct eea_net_tx *tx;
int err, i;
- ctx->tx = kvcalloc(ctx->cfg.tx_ring_num, sizeof(*ctx->tx), GFP_KERNEL);
+ ctx->tx = kvzalloc_objs(*ctx->tx, ctx->cfg.tx_ring_num);
if (!ctx->tx)
return -ENOMEM;
- ctx->rx = kvcalloc(ctx->cfg.rx_ring_num, sizeof(*ctx->rx), GFP_KERNEL);
+ ctx->rx = kvzalloc_objs(*ctx->rx, ctx->cfg.rx_ring_num);
if (!ctx->rx)
goto err_free_tx;
@@ -601,7 +601,7 @@ static int eea_netdev_init_features(struct net_device *netdev,
int err;
u32 mtu;
- cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ cfg = kzalloc_obj(*cfg);
if (!cfg)
return -ENOMEM;
diff --git a/drivers/net/ethernet/alibaba/eea/eea_pci.c b/drivers/net/ethernet/alibaba/eea/eea_pci.c
index 9872e360dd5d..c625b58b26f0 100644
--- a/drivers/net/ethernet/alibaba/eea/eea_pci.c
+++ b/drivers/net/ethernet/alibaba/eea/eea_pci.c
@@ -651,7 +651,7 @@ static int eea_pci_probe(struct pci_dev *pci_dev,
struct eea_device *edev;
int err;
- ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL);
+ ep_dev = kzalloc_obj(*ep_dev);
if (!ep_dev)
return -ENOMEM;
diff --git a/drivers/net/ethernet/alibaba/eea/eea_ring.c b/drivers/net/ethernet/alibaba/eea/eea_ring.c
index 99dcabd094b8..fac7d4647ecb 100644
--- a/drivers/net/ethernet/alibaba/eea/eea_ring.c
+++ b/drivers/net/ethernet/alibaba/eea/eea_ring.c
@@ -217,7 +217,7 @@ struct eea_ring *eea_ering_alloc(u32 index, u32 num, struct eea_device *edev,
if (!cq_desc_size || !is_power_of_2(cq_desc_size))
return NULL;
- ering = kzalloc(sizeof(*ering), GFP_KERNEL);
+ ering = kzalloc_obj(*ering);
if (!ering)
return NULL;
diff --git a/drivers/net/ethernet/alibaba/eea/eea_rx.c b/drivers/net/ethernet/alibaba/eea/eea_rx.c
index a3f0d2a79ad8..5dfb7cb2ba6d 100644
--- a/drivers/net/ethernet/alibaba/eea/eea_rx.c
+++ b/drivers/net/ethernet/alibaba/eea/eea_rx.c
@@ -764,7 +764,7 @@ struct eea_net_rx *eea_alloc_rx(struct eea_net_init_ctx *ctx, u32 idx)
struct eea_net_rx *rx;
int err;
- rx = kzalloc(sizeof(*rx), GFP_KERNEL);
+ rx = kzalloc_obj(*rx);
if (!rx)
return rx;
@@ -786,8 +786,7 @@ struct eea_net_rx *eea_alloc_rx(struct eea_net_init_ctx *ctx, u32 idx)
rx->dma_dev = ctx->edev->dma_dev;
/* meta */
- rx->meta = kvcalloc(ctx->cfg.rx_ring_depth,
- sizeof(*rx->meta), GFP_KERNEL);
+ rx->meta = kvzalloc_objs(*rx->meta, ctx->cfg.rx_ring_depth);
if (!rx->meta)
goto err_free_rx;
diff --git a/drivers/net/ethernet/alibaba/eea/eea_tx.c b/drivers/net/ethernet/alibaba/eea/eea_tx.c
index 85fb0e9ca5ba..c9292bca1a8b 100644
--- a/drivers/net/ethernet/alibaba/eea/eea_tx.c
+++ b/drivers/net/ethernet/alibaba/eea/eea_tx.c
@@ -480,8 +480,7 @@ int eea_alloc_tx(struct eea_net_init_ctx *ctx, struct eea_net_tx *tx, u32 idx)
tx->dma_dev = ctx->edev->dma_dev;
/* meta */
- tx->meta = kvcalloc(ctx->cfg.tx_ring_depth,
- sizeof(*tx->meta), GFP_KERNEL);
+ tx->meta = kvzalloc_objs(*tx->meta, ctx->cfg.tx_ring_depth);
if (!tx->meta)
goto err_free_tx;
diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
index 922e3ec8af1b..419e4b6ac983 100644
--- a/drivers/net/ethernet/amd/pds_core/core.c
+++ b/drivers/net/ethernet/amd/pds_core/core.c
@@ -810,8 +810,7 @@ void pdsc_host_mem_add(struct pdsc *pdsc)
if (count == 0)
return;
- pdsc->host_mem_reqs = kzalloc_objs(*pdsc->host_mem_reqs, count,
- GFP_KERNEL);
+ pdsc->host_mem_reqs = kzalloc_objs(*pdsc->host_mem_reqs, count);
if (!pdsc->host_mem_reqs) {
dev_err(pdsc->dev, "failed to alloc host_mem_reqs array\n");
return;
diff --git a/drivers/net/ethernet/amd/pds_core/fw.c b/drivers/net/ethernet/amd/pds_core/fw.c
index 5ccf017f6af4..8551ce3cd86a 100644
--- a/drivers/net/ethernet/amd/pds_core/fw.c
+++ b/drivers/net/ethernet/amd/pds_core/fw.c
@@ -382,7 +382,7 @@ static int pdsc_send_package_data(struct pldmfw *context, const u8 *data,
if (!length)
return 0;
- deferred = kmalloc_obj(*deferred, GFP_KERNEL);
+ deferred = kmalloc_obj(*deferred);
if (!deferred)
return -ENOMEM;
@@ -505,7 +505,7 @@ static int pdsc_send_component_table(struct pldmfw *context,
component->version_string, component->index,
component->component_size, transfer_flag);
- component_priv = kzalloc_obj(*component_priv, GFP_KERNEL);
+ component_priv = kzalloc_obj(*component_priv);
if (!component_priv)
return -ENOMEM;
@@ -710,7 +710,7 @@ static int pdsc_flash_component_chunk(struct pdsc *pdsc, struct device *dev,
u8 *component_data;
int err;
- deferred = kmalloc_obj(*deferred, GFP_KERNEL);
+ deferred = kmalloc_obj(*deferred);
if (!deferred)
return -ENOMEM;
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index b1939da4c95a..daa8a4a149e9 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4334,7 +4334,7 @@ static int macb_taprio_setup_replace(struct net_device *netdev,
return -EINVAL;
}
- enst_queue = kcalloc(conf->num_entries, sizeof(*enst_queue), GFP_KERNEL);
+ enst_queue = kzalloc_objs(*enst_queue, conf->num_entries);
if (unlikely(!enst_queue))
return -ENOMEM;
diff --git a/drivers/net/ethernet/cisco/enic/enic_admin.c b/drivers/net/ethernet/cisco/enic/enic_admin.c
index 7188f1b81c04..61c82b48044d 100644
--- a/drivers/net/ethernet/cisco/enic/enic_admin.c
+++ b/drivers/net/ethernet/cisco/enic/enic_admin.c
@@ -137,7 +137,7 @@ static void enic_admin_msg_enqueue(struct enic *enic, void *buf,
{
struct enic_admin_msg *msg;
- msg = kmalloc(struct_size(msg, data, len), GFP_KERNEL);
+ msg = kmalloc_flex(*msg, data, len);
if (!msg)
return;
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 0baef7a120ec..65830c1d3ff6 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -2858,7 +2858,7 @@ enic_sriov_v2_enable(struct enic *enic, int num_vfs)
return -EOPNOTSUPP;
}
- enic->vf_state = kcalloc(num_vfs, sizeof(*enic->vf_state), GFP_KERNEL);
+ enic->vf_state = kzalloc_objs(*enic->vf_state, num_vfs);
if (!enic->vf_state)
return -ENOMEM;
@@ -2946,7 +2946,7 @@ enic_sriov_configure(struct pci_dev *pdev, int num_vfs)
if (enic->vf_type == ENIC_VF_TYPE_V2)
return enic_sriov_v2_enable(enic, num_vfs);
- pp = kcalloc(num_vfs, sizeof(*pp), GFP_KERNEL);
+ pp = kzalloc_objs(*pp, num_vfs);
if (!pp)
return -ENOMEM;
@@ -2971,7 +2971,7 @@ enic_sriov_configure(struct pci_dev *pdev, int num_vfs)
return 0;
}
- pp = kzalloc_obj(*enic->pp, GFP_KERNEL);
+ pp = kzalloc_obj(*enic->pp);
if (!pp)
return -ENOMEM;
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 79d4a77f72bd..8cabce0eb2ab 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -616,7 +616,7 @@ static int dpaa2_switch_lag_fdb_add(struct dpaa2_switch_lag *lag,
goto out;
}
- a = kzalloc(sizeof(*a), GFP_KERNEL);
+ a = kzalloc_obj(*a);
if (!a) {
err = -ENOMEM;
goto out;
@@ -4131,8 +4131,7 @@ static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev)
goto err_free_fdbs;
}
- ethsw->lags = kcalloc(ethsw->sw_attr.num_ifs, sizeof(*ethsw->lags),
- GFP_KERNEL);
+ ethsw->lags = kzalloc_objs(*ethsw->lags, ethsw->sw_attr.num_ifs);
if (!ethsw->lags) {
err = -ENOMEM;
goto err_free_filter;
diff --git a/drivers/net/ethernet/intel/libie/controlq.c b/drivers/net/ethernet/intel/libie/controlq.c
index 45a49eba6a82..6214fc036ce5 100644
--- a/drivers/net/ethernet/intel/libie/controlq.c
+++ b/drivers/net/ethernet/intel/libie/controlq.c
@@ -157,8 +157,7 @@ static void libie_ctlq_free_tx_msgs(struct libie_ctlq_info *ctlq,
*/
static int libie_ctlq_alloc_tx_msgs(struct libie_ctlq_info *ctlq)
{
- ctlq->tx_msg = kvzalloc_objs(*ctlq->tx_msg, ctlq->ring_len,
- GFP_KERNEL);
+ ctlq->tx_msg = kvzalloc_objs(*ctlq->tx_msg, ctlq->ring_len);
if (!ctlq->tx_msg)
return -ENOMEM;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
index 3070700b952b..2b67671a2bd8 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
@@ -3647,7 +3647,7 @@ static int npc_defrag_add_2_show_list(struct rvu *rvu, u16 old_midx,
{
struct npc_defrag_show_node *node;
- node = kcalloc(1, sizeof(*node), GFP_KERNEL);
+ node = kzalloc_objs(*node, 1);
if (!node)
return -ENOMEM;
@@ -4082,7 +4082,7 @@ int npc_cn20k_defrag(struct rvu *rvu)
INIT_LIST_HEAD(&x4lh);
INIT_LIST_HEAD(&x2lh);
- node = kcalloc(npc_priv->num_subbanks, sizeof(*node), GFP_KERNEL);
+ node = kzalloc_objs(*node, npc_priv->num_subbanks);
if (!node)
return -ENOMEM;
@@ -4711,7 +4711,7 @@ static int npc_priv_init(struct rvu *rvu)
return -EINVAL;
}
- npc_priv = kcalloc(1, sizeof(*npc_priv), GFP_KERNEL);
+ npc_priv = kzalloc_objs(*npc_priv, 1);
if (!npc_priv)
return -ENOMEM;
@@ -4729,8 +4729,7 @@ static int npc_priv_init(struct rvu *rvu)
num_banks, bank_depth, num_subbanks, subbank_depth,
npc_kw_name[npc_priv->kw]);
- npc_priv->sb = kcalloc(num_subbanks, sizeof(struct npc_subbank),
- GFP_KERNEL);
+ npc_priv->sb = kzalloc_objs(struct npc_subbank, num_subbanks);
if (!npc_priv->sb)
goto fail1;
@@ -4757,9 +4756,7 @@ static int npc_priv_init(struct rvu *rvu)
/* Get number of pcifuncs in the system */
npc_priv->pf_cnt = npc_pcifunc_map_create(rvu);
- npc_priv->xa_pf2idx_map = kcalloc(npc_priv->pf_cnt,
- sizeof(struct xarray),
- GFP_KERNEL);
+ npc_priv->xa_pf2idx_map = kzalloc_objs(struct xarray, npc_priv->pf_cnt);
if (!npc_priv->xa_pf2idx_map) {
ret = -ENOMEM;
goto fail3;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index b6e2c153b4f7..60d477c4eb25 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -2288,8 +2288,7 @@ static int mlx5_esw_spfs_init(struct mlx5_eswitch *esw)
if (!num_entries)
goto out_free;
- esw_funcs->spfs = kcalloc(num_entries, sizeof(*esw_funcs->spfs),
- GFP_KERNEL);
+ esw_funcs->spfs = kzalloc_objs(*esw_funcs->spfs, num_entries);
if (!esw_funcs->spfs) {
err = -ENOMEM;
goto out_free;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index d603e294ee0e..eb74b6260168 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -1524,7 +1524,7 @@ struct mlx5_flow_handle *
mlx5_esw_lag_demux_rule_create(struct mlx5_eswitch *esw, u16 vport_num,
struct mlx5_flow_table *lag_ft)
{
- struct mlx5_flow_spec *spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
+ struct mlx5_flow_spec *spec = kvzalloc_obj(*spec);
struct mlx5_flow_destination dest = {};
struct mlx5_flow_act flow_act = {};
struct mlx5_flow_handle *ret;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c
index 95a8b1e64ba4..1724bf7e0e7a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c
@@ -317,7 +317,7 @@ int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev)
num_spfs = mlx5_esw_get_num_spfs(dev);
num_hwc = MLX5_SF_HWC_FIRST_SPF + num_spfs;
- table->hwc = kcalloc(num_hwc, sizeof(*table->hwc), GFP_KERNEL);
+ table->hwc = kzalloc_objs(*table->hwc, num_hwc);
if (!table->hwc) {
err = -ENOMEM;
goto hwc_alloc_err;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
index fa4d24b3dfaa..1b928b40686e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
@@ -239,7 +239,7 @@ static int dr_icm_buddy_init_ste_cache(struct mlx5dr_icm_buddy_mem *buddy)
if (!buddy->hw_ste_arr)
goto free_ste_arr;
- buddy->miss_list = kvmalloc_array(num_of_entries, sizeof(struct list_head), GFP_KERNEL);
+ buddy->miss_list = kvmalloc_objs(struct list_head, num_of_entries);
if (!buddy->miss_list)
goto free_hw_ste_arr;
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_irq.c b/drivers/net/ethernet/meta/fbnic/fbnic_irq.c
index 5e383d40abc7..ec3b628ecb2d 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_irq.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_irq.c
@@ -282,7 +282,7 @@ enum fbnic_msix_self_test_codes fbnic_msix_test(struct fbnic_dev *fbd)
int i;
/* Allocate bitmap and IRQ vector table */
- test_data = kzalloc_obj(*test_data, GFP_KERNEL);
+ test_data = kzalloc_obj(*test_data);
/* memory allocation failure */
if (!test_data)
diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c
index f92b2d0bf926..8e9bfc1d6a2a 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -429,11 +429,11 @@ int mana_gd_alloc_memory(struct gdma_context *gc, unsigned int length,
/* length is a power of 2 above PAGE_SIZE, so this divides exactly. */
npages = length / PAGE_SIZE;
- gmi->pages_va = kvcalloc(npages, sizeof(*gmi->pages_va), GFP_KERNEL);
+ gmi->pages_va = kvzalloc_objs(*gmi->pages_va, npages);
if (!gmi->pages_va)
return -ENOMEM;
- gmi->pages_dma = kvcalloc(npages, sizeof(*gmi->pages_dma), GFP_KERNEL);
+ gmi->pages_dma = kvzalloc_objs(*gmi->pages_dma, npages);
if (!gmi->pages_dma)
goto free_va;
@@ -825,7 +825,7 @@ int mana_schedule_serv_work(struct gdma_context *gc, enum gdma_eqe_type type)
return -ENODEV;
}
- mns_wk = kzalloc(sizeof(*mns_wk), GFP_ATOMIC);
+ mns_wk = kzalloc_obj(*mns_wk, GFP_ATOMIC);
if (!mns_wk) {
module_put(THIS_MODULE);
clear_bit(GC_IN_SERVICE, &gc->flags);
@@ -1991,7 +1991,7 @@ struct gdma_irq_context *mana_gd_get_gic(struct gdma_context *gc,
*msi_requested = msi;
}
- gic = kzalloc(sizeof(*gic), GFP_KERNEL);
+ gic = kzalloc_obj(*gic);
if (!gic) {
gic = ERR_PTR(-ENOMEM);
if (irq_map.virq)
diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
index 2c04be6d61a8..7a0d5e892a1a 100644
--- a/drivers/net/ntb_netdev.c
+++ b/drivers/net/ntb_netdev.c
@@ -659,8 +659,7 @@ static int ntb_netdev_probe(struct device *client_dev)
dev->client_dev = client_dev;
dev->num_queues = 0;
- dev->queues = kzalloc_objs(*dev->queues, NTB_NETDEV_MAX_QUEUES,
- GFP_KERNEL);
+ dev->queues = kzalloc_objs(*dev->queues, NTB_NETDEV_MAX_QUEUES);
if (!dev->queues) {
rc = -ENOMEM;
goto err_free_netdev;
diff --git a/drivers/net/wireless/ath/ath12k/ahb.c b/drivers/net/wireless/ath/ath12k/ahb.c
index 0fc55c9169e1..d89a49c6ebb7 100644
--- a/drivers/net/wireless/ath/ath12k/ahb.c
+++ b/drivers/net/wireless/ath/ath12k/ahb.c
@@ -870,7 +870,7 @@ static struct ath12k_ahb_rproc_info *ath12k_ahb_rproc_info_alloc(struct ath12k_b
lockdep_assert_held(&ath12k_rproc_info_lock);
- rproc_info = kzalloc_obj(*rproc_info, GFP_KERNEL);
+ rproc_info = kzalloc_obj(*rproc_info);
if (!rproc_info)
return NULL;
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/regulatory.c b/drivers/net/wireless/intel/iwlwifi/mld/regulatory.c
index 533870cf443f..6db84c2117f2 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/regulatory.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/regulatory.c
@@ -514,8 +514,7 @@ void iwl_mld_init_ap_type_tables(struct iwl_mld *mld)
return;
if (iwl_fw_lookup_cmd_ver(mld->fw, cmd.id, 1) == 1) {
- struct iwl_mcc_allowed_ap_type_cmd_v1 *cmd_v1 =
- kzalloc(sizeof(*cmd_v1), GFP_KERNEL);
+ struct iwl_mcc_allowed_ap_type_cmd_v1 *cmd_v1 = kzalloc_obj(*cmd_v1);
if (!cmd_v1)
return;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/regd.c b/drivers/net/wireless/mediatek/mt76/mt7921/regd.c
index 4a8ea4624fee..fcdeb65cd8ef 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/regd.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/regd.c
@@ -289,7 +289,7 @@ int mt7921_regd_update(struct mt792x_phy *phy, char *alpha2)
goto err;
}
- regd = kzalloc(struct_size(regd, reg_rules, num_of_rules), GFP_KERNEL);
+ regd = kzalloc_flex(*regd, reg_rules, num_of_rules);
if (!regd) {
ret = -ENOMEM;
goto err;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 84b55f008b3d..5993b31e1aae 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1105,7 +1105,7 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
mlink = &msta->deflink;
is_deflink = true;
} else {
- mlink = kzalloc(sizeof(*mlink), GFP_KERNEL);
+ mlink = kzalloc_obj(*mlink);
if (!mlink) {
err = -ENOMEM;
break;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/regd.c b/drivers/net/wireless/mediatek/mt76/mt7925/regd.c
index f4beb7f52043..57f1736b54a3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/regd.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/regd.c
@@ -336,7 +336,7 @@ int mt7925_regd_update(struct mt792x_phy *phy, char *alpha2)
goto err;
}
- regd = kzalloc(struct_size(regd, reg_rules, num_of_rules), GFP_KERNEL);
+ regd = kzalloc_flex(*regd, reg_rules, num_of_rules);
if (!regd) {
ret = -ENOMEM;
goto err;
diff --git a/drivers/net/wireless/morsemicro/mm81x/mac.c b/drivers/net/wireless/morsemicro/mm81x/mac.c
index 08ca116a68b4..0fa80b1488aa 100644
--- a/drivers/net/wireless/morsemicro/mm81x/mac.c
+++ b/drivers/net/wireless/morsemicro/mm81x/mac.c
@@ -706,8 +706,7 @@ static int mm81x_hw_scan_h_init_chan_list(struct mm81x_hw_scan_params *params,
params->num_chans = 0;
params->allocated_chans = 0;
- params->channels = kcalloc(chans_to_allocate, sizeof(*params->channels),
- GFP_KERNEL);
+ params->channels = kzalloc_objs(*params->channels, chans_to_allocate);
if (!params->channels)
return -ENOMEM;
@@ -728,8 +727,8 @@ static int mm81x_hw_scan_h_init_chan_list(struct mm81x_hw_scan_params *params,
}
}
- params->powers_qdbm = kmalloc_array(
- num_pwrs_coarse, sizeof(*params->powers_qdbm), GFP_KERNEL);
+ params->powers_qdbm = kmalloc_objs(*params->powers_qdbm,
+ num_pwrs_coarse);
if (!params->powers_qdbm)
return -ENOMEM;
@@ -822,7 +821,7 @@ __mm81x_hw_scan_h_init_params(struct mm81x *mors)
struct mm81x_hw_scan_params *params = mors->hw_scan.params;
if (!params) {
- params = kzalloc_obj(*params, GFP_KERNEL);
+ params = kzalloc_obj(*params);
if (params)
mors->hw_scan.params = params;
} else {
diff --git a/drivers/net/wireless/morsemicro/mm81x/yaps.c b/drivers/net/wireless/morsemicro/mm81x/yaps.c
index e98a2a58726f..2d1728c1a6de 100644
--- a/drivers/net/wireless/morsemicro/mm81x/yaps.c
+++ b/drivers/net/wireless/morsemicro/mm81x/yaps.c
@@ -22,15 +22,13 @@
static int mm81x_yaps_alloc_pkt_buffers(struct mm81x_yaps *yaps)
{
- yaps->hw.to_chip_pkts = kcalloc(MAX_PKTS_PER_TX_TXN,
- sizeof(*yaps->hw.to_chip_pkts),
- GFP_KERNEL);
+ yaps->hw.to_chip_pkts = kzalloc_objs(*yaps->hw.to_chip_pkts,
+ MAX_PKTS_PER_TX_TXN);
if (!yaps->hw.to_chip_pkts)
return -ENOMEM;
- yaps->hw.from_chip_pkts = kcalloc(MAX_PKTS_PER_RX_TXN,
- sizeof(*yaps->hw.from_chip_pkts),
- GFP_KERNEL);
+ yaps->hw.from_chip_pkts = kzalloc_objs(*yaps->hw.from_chip_pkts,
+ MAX_PKTS_PER_RX_TXN);
if (!yaps->hw.from_chip_pkts) {
kfree(yaps->hw.to_chip_pkts);
yaps->hw.to_chip_pkts = NULL;
diff --git a/drivers/net/wireless/nxp/nxpwifi/cfg80211.c b/drivers/net/wireless/nxp/nxpwifi/cfg80211.c
index 5cc8cdf594d3..86304ea3331c 100644
--- a/drivers/net/wireless/nxp/nxpwifi/cfg80211.c
+++ b/drivers/net/wireless/nxp/nxpwifi/cfg80211.c
@@ -641,7 +641,7 @@ nxpwifi_cfg80211_set_wiphy_params(struct wiphy *wiphy, int radio_idx, u32 change
switch (priv->bss_role) {
case NXPWIFI_BSS_ROLE_UAP:
- bss_cfg = kzalloc_obj(*bss_cfg, GFP_KERNEL);
+ bss_cfg = kzalloc_obj(*bss_cfg);
if (!bss_cfg) {
ret = -ENOMEM;
break;
@@ -1713,7 +1713,7 @@ static int nxpwifi_cfg80211_start_ap(struct wiphy *wiphy,
if (!nxpwifi_is_channel_setting_allowable(priv, params->chandef.chan))
return -EOPNOTSUPP;
- bss_cfg = kzalloc_obj(*bss_cfg, GFP_KERNEL);
+ bss_cfg = kzalloc_obj(*bss_cfg);
if (!bss_cfg)
return -ENOMEM;
@@ -1866,7 +1866,7 @@ nxpwifi_cfg80211_scan(struct wiphy *wiphy,
if (!nxpwifi_stop_bg_scan(priv))
cfg80211_sched_scan_stopped_locked(priv->wdev.wiphy, 0);
- user_scan_cfg = kzalloc_obj(*user_scan_cfg, GFP_KERNEL);
+ user_scan_cfg = kzalloc_obj(*user_scan_cfg);
if (!user_scan_cfg)
return -ENOMEM;
@@ -1973,7 +1973,7 @@ nxpwifi_cfg80211_sched_scan_start(struct wiphy *wiphy,
request->n_channels, request->scan_plans->interval,
(int)request->ie_len);
- bgscan_cfg = kzalloc_obj(*bgscan_cfg, GFP_KERNEL);
+ bgscan_cfg = kzalloc_obj(*bgscan_cfg);
if (!bgscan_cfg)
return -ENOMEM;
@@ -2304,7 +2304,7 @@ nxpwifi_setup_he_caps(struct nxpwifi_private *priv,
if (!hw_he_cap_len)
return;
- iftype_data = kmalloc_obj(*iftype_data, GFP_KERNEL);
+ iftype_data = kmalloc_obj(*iftype_data);
if (!iftype_data)
return;
memset(iftype_data, 0, sizeof(*iftype_data));
@@ -2759,7 +2759,7 @@ static int nxpwifi_set_mef_filter(struct nxpwifi_private *priv,
if (wowlan->n_patterns || wowlan->magic_pkt)
num_entries++;
- mef_entry = kzalloc_objs(*mef_entry, num_entries, GFP_KERNEL);
+ mef_entry = kzalloc_objs(*mef_entry, num_entries);
if (!mef_entry)
return -ENOMEM;
@@ -3227,7 +3227,7 @@ static int nxpwifi_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev,
if (!tb[NXPWIFI_TM_ATTR_DATA])
return -EINVAL;
- hostcmd = kzalloc_obj(*hostcmd, GFP_KERNEL);
+ hostcmd = kzalloc_obj(*hostcmd);
if (!hostcmd)
return -ENOMEM;
diff --git a/drivers/net/wireless/nxp/nxpwifi/cmdevt.c b/drivers/net/wireless/nxp/nxpwifi/cmdevt.c
index 4eb17ada5db8..fc1950a125b6 100644
--- a/drivers/net/wireless/nxp/nxpwifi/cmdevt.c
+++ b/drivers/net/wireless/nxp/nxpwifi/cmdevt.c
@@ -302,7 +302,7 @@ int nxpwifi_alloc_cmd_buffer(struct nxpwifi_adapter *adapter)
/* Allocate and initialize struct cmd_ctrl_node */
cmd_array = kzalloc_objs(struct cmd_ctrl_node,
- NXPWIFI_NUM_OF_CMD_BUFFER, GFP_KERNEL);
+ NXPWIFI_NUM_OF_CMD_BUFFER);
if (!cmd_array)
return -ENOMEM;
diff --git a/drivers/net/wireless/nxp/nxpwifi/ie.c b/drivers/net/wireless/nxp/nxpwifi/ie.c
index 158755c0c905..86b18d50feaf 100644
--- a/drivers/net/wireless/nxp/nxpwifi/ie.c
+++ b/drivers/net/wireless/nxp/nxpwifi/ie.c
@@ -143,7 +143,7 @@ nxpwifi_update_uap_custom_ie(struct nxpwifi_private *priv,
u16 len;
int ret;
- ap_custom_ie = kzalloc_obj(*ap_custom_ie, GFP_KERNEL);
+ ap_custom_ie = kzalloc_obj(*ap_custom_ie);
if (!ap_custom_ie)
return -ENOMEM;
@@ -209,7 +209,7 @@ static int nxpwifi_update_vs_ie(const u8 *ies, int ies_len,
vendor_ie = cfg80211_find_vendor_ie(oui, oui_type, ies, ies_len);
if (vendor_ie) {
if (!*ie_ptr) {
- *ie_ptr = kzalloc_obj(struct nxpwifi_ie, GFP_KERNEL);
+ *ie_ptr = kzalloc_obj(struct nxpwifi_ie);
if (!*ie_ptr)
return -ENOMEM;
ie = *ie_ptr;
@@ -309,7 +309,7 @@ static int nxpwifi_uap_parse_tail_ies(struct nxpwifi_private *priv,
if (!info->tail || !info->tail_len)
return 0;
- gen_ie = kzalloc_obj(*gen_ie, GFP_KERNEL);
+ gen_ie = kzalloc_obj(*gen_ie);
if (!gen_ie)
return -ENOMEM;
@@ -417,7 +417,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv)
int ret = 0;
if (priv->gen_idx != NXPWIFI_AUTO_IDX_MASK) {
- gen_ie = kmalloc_obj(*gen_ie, GFP_KERNEL);
+ gen_ie = kmalloc_obj(*gen_ie);
if (!gen_ie)
return -ENOMEM;
@@ -434,7 +434,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv)
}
if (priv->beacon_idx != NXPWIFI_AUTO_IDX_MASK) {
- beacon_ie = kmalloc_obj(*beacon_ie, GFP_KERNEL);
+ beacon_ie = kmalloc_obj(*beacon_ie);
if (!beacon_ie) {
ret = -ENOMEM;
goto done;
@@ -444,7 +444,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv)
beacon_ie->ie_length = 0;
}
if (priv->proberesp_idx != NXPWIFI_AUTO_IDX_MASK) {
- pr_ie = kmalloc_obj(*pr_ie, GFP_KERNEL);
+ pr_ie = kmalloc_obj(*pr_ie);
if (!pr_ie) {
ret = -ENOMEM;
goto done;
@@ -454,7 +454,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv)
pr_ie->ie_length = 0;
}
if (priv->assocresp_idx != NXPWIFI_AUTO_IDX_MASK) {
- ar_ie = kmalloc_obj(*ar_ie, GFP_KERNEL);
+ ar_ie = kmalloc_obj(*ar_ie);
if (!ar_ie) {
ret = -ENOMEM;
goto done;
diff --git a/drivers/net/wireless/nxp/nxpwifi/init.c b/drivers/net/wireless/nxp/nxpwifi/init.c
index b128fc9fe31a..7c75dca5d0a8 100644
--- a/drivers/net/wireless/nxp/nxpwifi/init.c
+++ b/drivers/net/wireless/nxp/nxpwifi/init.c
@@ -20,7 +20,7 @@ static int nxpwifi_add_bss_prio_tbl(struct nxpwifi_private *priv)
struct nxpwifi_bss_prio_node *bss_prio;
struct nxpwifi_bss_prio_tbl *tbl = adapter->bss_prio_tbl;
- bss_prio = kzalloc_obj(*bss_prio, GFP_KERNEL);
+ bss_prio = kzalloc_obj(*bss_prio);
if (!bss_prio)
return -ENOMEM;
diff --git a/drivers/net/wireless/nxp/nxpwifi/main.c b/drivers/net/wireless/nxp/nxpwifi/main.c
index b4c63829024a..55b962430f37 100644
--- a/drivers/net/wireless/nxp/nxpwifi/main.c
+++ b/drivers/net/wireless/nxp/nxpwifi/main.c
@@ -32,7 +32,7 @@ static struct nxpwifi_adapter *nxpwifi_register(void *card, struct device *dev,
int ret = 0;
int i;
- adapter = kzalloc_obj(*adapter, GFP_KERNEL);
+ adapter = kzalloc_obj(*adapter);
if (!adapter)
return ERR_PTR(-ENOMEM);
@@ -55,7 +55,7 @@ static struct nxpwifi_adapter *nxpwifi_register(void *card, struct device *dev,
for (i = 0; i < NXPWIFI_MAX_BSS_NUM; i++) {
/* Allocate memory for private structure */
adapter->priv[i] =
- kzalloc_obj(struct nxpwifi_private, GFP_KERNEL);
+ kzalloc_obj(struct nxpwifi_private);
if (!adapter->priv[i]) {
ret = -ENOMEM;
goto error;
@@ -1106,7 +1106,7 @@ void nxpwifi_drv_info_dump(struct nxpwifi_adapter *adapter)
p += adapter->if_ops.reg_dump(adapter, p);
}
p += sprintf(p, "\n=== more debug information\n");
- debug_info = kzalloc_obj(*debug_info, GFP_KERNEL);
+ debug_info = kzalloc_obj(*debug_info);
if (debug_info) {
for (i = 0; i < adapter->priv_num; i++) {
if (!adapter->priv[i]->netdev)
@@ -1242,7 +1242,7 @@ void nxpwifi_init_priv_params(struct nxpwifi_private *priv,
if (GET_BSS_ROLE(priv) == NXPWIFI_BSS_ROLE_STA ||
GET_BSS_ROLE(priv) == NXPWIFI_BSS_ROLE_UAP) {
- priv->hist_data = kmalloc_obj(*priv->hist_data, GFP_KERNEL);
+ priv->hist_data = kmalloc_obj(*priv->hist_data);
if (priv->hist_data)
nxpwifi_hist_data_reset(priv);
}
diff --git a/drivers/net/wireless/nxp/nxpwifi/scan.c b/drivers/net/wireless/nxp/nxpwifi/scan.c
index b77056983e83..67d7ff2f10c5 100644
--- a/drivers/net/wireless/nxp/nxpwifi/scan.c
+++ b/drivers/net/wireless/nxp/nxpwifi/scan.c
@@ -1341,15 +1341,14 @@ int nxpwifi_scan_networks(struct nxpwifi_private *priv,
adapter->scan_processing = true;
spin_unlock_bh(&adapter->nxpwifi_cmd_lock);
- scan_cfg_out = kzalloc_obj(union nxpwifi_scan_cmd_config_tlv,
- GFP_KERNEL);
+ scan_cfg_out = kzalloc_obj(union nxpwifi_scan_cmd_config_tlv);
if (!scan_cfg_out) {
ret = -ENOMEM;
goto done;
}
scan_chan_list = kzalloc_objs(struct nxpwifi_chan_scan_param_set,
- NXPWIFI_USER_SCAN_CHAN_MAX, GFP_KERNEL);
+ NXPWIFI_USER_SCAN_CHAN_MAX);
if (!scan_chan_list) {
kfree(scan_cfg_out);
ret = -ENOMEM;
@@ -1471,7 +1470,7 @@ static int nxpwifi_save_hidden_ssid_channels(struct nxpwifi_private *priv,
int chid;
/* Allocate and fill new bss descriptor */
- bss_desc = kzalloc_obj(*bss_desc, GFP_KERNEL);
+ bss_desc = kzalloc_obj(*bss_desc);
if (!bss_desc)
return -ENOMEM;
@@ -1512,7 +1511,7 @@ static int nxpwifi_update_curr_bss_params(struct nxpwifi_private *priv,
int ret;
/* Allocate and fill new bss descriptor */
- bss_desc = kzalloc_obj(*bss_desc, GFP_KERNEL);
+ bss_desc = kzalloc_obj(*bss_desc);
if (!bss_desc)
return -ENOMEM;
@@ -1751,7 +1750,7 @@ nxpwifi_active_scan_req_for_passive_chan(struct nxpwifi_private *priv)
nxpwifi_dbg(adapter, INFO, "No BSS with hidden SSID found on DFS channels\n");
return 0;
}
- user_scan_cfg = kzalloc_obj(*user_scan_cfg, GFP_KERNEL);
+ user_scan_cfg = kzalloc_obj(*user_scan_cfg);
if (!user_scan_cfg)
return -ENOMEM;
@@ -2258,7 +2257,7 @@ int nxpwifi_stop_bg_scan(struct nxpwifi_private *priv)
return 0;
}
- bgscan_cfg = kzalloc_obj(*bgscan_cfg, GFP_KERNEL);
+ bgscan_cfg = kzalloc_obj(*bgscan_cfg);
if (!bgscan_cfg)
return -ENOMEM;
diff --git a/drivers/net/wireless/nxp/nxpwifi/sta_cfg.c b/drivers/net/wireless/nxp/nxpwifi/sta_cfg.c
index 702fa1531da1..56cf63fbf7fe 100644
--- a/drivers/net/wireless/nxp/nxpwifi/sta_cfg.c
+++ b/drivers/net/wireless/nxp/nxpwifi/sta_cfg.c
@@ -245,7 +245,7 @@ int nxpwifi_bss_start(struct nxpwifi_private *priv, struct cfg80211_bss *bss,
return -EINVAL;
/* Allocate and fill new bss descriptor */
- bss_desc = kzalloc_obj(*bss_desc, GFP_KERNEL);
+ bss_desc = kzalloc_obj(*bss_desc);
if (!bss_desc)
return -ENOMEM;
diff --git a/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c b/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
index 5e8ffd306b31..9bfa4aebc3e5 100644
--- a/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
+++ b/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
@@ -2822,7 +2822,7 @@ nxpwifi_create_custom_regdomain(struct nxpwifi_private *priv,
if (WARN_ON_ONCE(num_chan > NL80211_MAX_SUPP_REG_RULES))
return ERR_PTR(-EINVAL);
- regd = kzalloc_flex(*regd, reg_rules, num_chan, GFP_KERNEL);
+ regd = kzalloc_flex(*regd, reg_rules, num_chan);
if (!regd)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/net/wireless/nxp/nxpwifi/uap_event.c b/drivers/net/wireless/nxp/nxpwifi/uap_event.c
index 9f717a3d7ec5..ab5c15686f54 100644
--- a/drivers/net/wireless/nxp/nxpwifi/uap_event.c
+++ b/drivers/net/wireless/nxp/nxpwifi/uap_event.c
@@ -88,7 +88,7 @@ nxpwifi_uap_event_sta_assoc(struct nxpwifi_private *priv)
struct nxpwifi_sta_node *node;
int len, i;
- sinfo = kzalloc_obj(*sinfo, GFP_KERNEL);
+ sinfo = kzalloc_obj(*sinfo);
if (!sinfo)
return -ENOMEM;
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index 24f42b4650ba..09842ca68110 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -1002,8 +1002,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
nd_region->num_lanes = ndr_desc->num_lanes;
if (!nd_region->num_lanes)
goto err_percpu;
- nd_region->lane = kcalloc(nd_region->num_lanes,
- sizeof(*nd_region->lane), GFP_KERNEL);
+ nd_region->lane = kzalloc_objs(*nd_region->lane, nd_region->num_lanes);
if (!nd_region->lane)
goto err_percpu;
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 1322c678f4eb..b16cec1ff51f 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2382,8 +2382,7 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
if (!head->nr_plids)
goto free;
- head->plids = kcalloc(head->nr_plids, sizeof(*head->plids),
- GFP_KERNEL);
+ head->plids = kzalloc_objs(*head->plids, head->nr_plids);
if (!head->plids) {
dev_warn(ctrl->device,
"failed to allocate %u FDP placement IDs\n",
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index da93b505d239..5440cf18b55b 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -201,7 +201,7 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
count++;
}
- qlist = kcalloc(count, sizeof(*qlist), GFP_KERNEL);
+ qlist = kzalloc_objs(*qlist, count);
if (!qlist) {
err = -ENOMEM;
goto out_free_val;
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index cd0e82dae776..2fafd983de8f 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -348,7 +348,7 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
count = opp_table->regulator_count;
- uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL);
+ uV = kmalloc_objs(*uV, count);
if (!uV)
return 0;
@@ -1505,7 +1505,7 @@ struct opp_device *_add_opp_dev(const struct device *dev,
{
struct opp_device *opp_dev;
- opp_dev = kzalloc(sizeof(*opp_dev), GFP_KERNEL);
+ opp_dev = kzalloc_obj(*opp_dev);
if (!opp_dev)
return NULL;
diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-ep-msi.c
index 0855c7930abb..9c13f193537d 100644
--- a/drivers/pci/endpoint/pci-ep-msi.c
+++ b/drivers/pci/endpoint/pci-ep-msi.c
@@ -57,7 +57,7 @@ static int pci_epf_alloc_doorbell_embedded(struct pci_epf *epf, u16 num_db)
return -ENODEV;
struct pci_epc_aux_resource *res __free(kfree) =
- kcalloc(count, sizeof(*res), GFP_KERNEL);
+ kzalloc_objs(*res, count);
if (!res)
return -ENOMEM;
@@ -98,7 +98,7 @@ static int pci_epf_alloc_doorbell_embedded(struct pci_epf *epf, u16 num_db)
addr = iova_base + off;
}
- msg = kcalloc(num_db, sizeof(*msg), GFP_KERNEL);
+ msg = kzalloc_objs(*msg, num_db);
if (!msg) {
ret = -ENOMEM;
goto err_unmap;
diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
index 8257cd1da48e..ddd7a04ee753 100644
--- a/drivers/platform/x86/amd/hsmp/acpi.c
+++ b/drivers/platform/x86/amd/hsmp/acpi.c
@@ -720,9 +720,8 @@ static int hsmp_acpi_probe(struct platform_device *pdev)
return -ENODEV;
}
- hsmp_pdev->sock = kcalloc(hsmp_pdev->num_sockets,
- sizeof(*hsmp_pdev->sock),
- GFP_KERNEL);
+ hsmp_pdev->sock = kzalloc_objs(*hsmp_pdev->sock,
+ hsmp_pdev->num_sockets);
if (!hsmp_pdev->sock)
return -ENOMEM;
diff --git a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
index 446dd18d2cee..72a4c2107d7e 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
@@ -96,8 +96,8 @@ int hp_alloc_enumeration_data(void)
if (!bioscfg_drv.enumeration_instances_count)
return -EINVAL;
- bioscfg_drv.enumeration_data = kvcalloc(bioscfg_drv.enumeration_instances_count,
- sizeof(*bioscfg_drv.enumeration_data), GFP_KERNEL);
+ bioscfg_drv.enumeration_data = kvzalloc_objs(*bioscfg_drv.enumeration_data,
+ bioscfg_drv.enumeration_instances_count);
if (!bioscfg_drv.enumeration_data) {
bioscfg_drv.enumeration_instances_count = 0;
diff --git a/drivers/platform/x86/intel/pmc/pwrm_telemetry.c b/drivers/platform/x86/intel/pmc/pwrm_telemetry.c
index 4cde241e01d6..013f779f20a4 100644
--- a/drivers/platform/x86/intel/pmc/pwrm_telemetry.c
+++ b/drivers/platform/x86/intel/pmc/pwrm_telemetry.c
@@ -93,8 +93,7 @@ acpi_disc_t pmc_parse_telem_dsd(union acpi_object *obj,
if (header->num_entries != num_regions)
return ERR_PTR(-EINVAL);
- acpi_disc_t disc __free(kfree) = kmalloc_array(num_regions, sizeof(*disc),
- GFP_KERNEL);
+ acpi_disc_t disc __free(kfree) = kmalloc_objs(*disc, num_regions);
if (!disc)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 842c4169e290..052ec478dfcc 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -2962,7 +2962,7 @@ int of_genpd_add_child_ids(struct device_node *np,
return -EINVAL;
/* Allocate tracking array for error unwind (parent/child pairs) */
- pairs = kmalloc_array(count * 2, sizeof(*pairs), GFP_KERNEL);
+ pairs = kmalloc_objs(*pairs, count * 2);
if (!pairs)
return -ENOMEM;
diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index af00c00eceee..3611bed341e1 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -122,14 +122,14 @@ static int reboot_mode_create_device(struct reboot_mode_driver *reboot)
struct mode_info *info;
int ret;
- priv = kzalloc_obj(*priv, GFP_KERNEL);
+ priv = kzalloc_obj(*priv);
if (!priv)
return -ENOMEM;
INIT_LIST_HEAD(&priv->head);
list_for_each_entry(info, &reboot->head, list) {
- sysfs_info = kzalloc_obj(*sysfs_info, GFP_KERNEL);
+ sysfs_info = kzalloc_obj(*sysfs_info);
if (!sysfs_info) {
ret = -ENOMEM;
goto error;
@@ -188,7 +188,7 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
continue;
}
- info = kzalloc_obj(*info, GFP_KERNEL);
+ info = kzalloc_obj(*info);
if (!info) {
ret = -ENOMEM;
goto error;
diff --git a/drivers/power/sequencing/core.c b/drivers/power/sequencing/core.c
index 721e888b658d..0cb71efbb268 100644
--- a/drivers/power/sequencing/core.c
+++ b/drivers/power/sequencing/core.c
@@ -480,7 +480,7 @@ pwrseq_device_register(const struct pwrseq_config *config)
!config->targets[0])
return ERR_PTR(-EINVAL);
- pwrseq = kzalloc(sizeof(*pwrseq), GFP_KERNEL);
+ pwrseq = kzalloc_obj(*pwrseq);
if (!pwrseq)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequencing/pwrseq-pcie-m2.c
index de9848a9a9f1..471ffe914a4e 100644
--- a/drivers/power/sequencing/pwrseq-pcie-m2.c
+++ b/drivers/power/sequencing/pwrseq-pcie-m2.c
@@ -291,7 +291,7 @@ static int pwrseq_pcie_m2_create_serdev_one(struct pwrseq_pcie_m2_ctx *ctx,
}
}
- pci_dev = kzalloc(sizeof(*pci_dev), GFP_KERNEL);
+ pci_dev = kzalloc_obj(*pci_dev);
if (!pci_dev) {
ret = -ENOMEM;
goto err_put_ctrl;
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 00d8bc98d588..47e307709e5e 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -904,7 +904,7 @@ int power_supply_get_battery_info(struct power_supply *psy,
goto out_put_node;
}
- u32 *propdata __free(kfree) = kcalloc(proplen, sizeof(*propdata), GFP_KERNEL);
+ u32 *propdata __free(kfree) = kzalloc_objs(*propdata, proplen);
if (!propdata) {
power_supply_put_battery_info(psy, info);
err = -EINVAL;
@@ -944,7 +944,7 @@ int power_supply_get_battery_info(struct power_supply *psy,
goto out_put_node;
}
- propdata = kcalloc(proplen, sizeof(*propdata), GFP_KERNEL);
+ propdata = kzalloc_objs(*propdata, proplen);
if (!propdata) {
power_supply_put_battery_info(psy, info);
err = -ENOMEM;
@@ -1726,7 +1726,7 @@ __power_supply_register(struct device *parent,
pr_warn("%s: Expected proper parent device for '%s'\n",
__func__, desc->name);
- psy = kzalloc(sizeof(*psy), GFP_KERNEL);
+ psy = kzalloc_obj(*psy);
if (!psy)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index dc23cd708cfe..f63b45f5ee6a 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -136,7 +136,7 @@ int ptp_open(struct posix_clock_context *pccontext, fmode_t fmode)
struct timestamp_event_queue *queue;
char debugfsname[32];
- queue = kzalloc(sizeof(*queue), GFP_KERNEL);
+ queue = kzalloc_obj(*queue);
if (!queue)
return -EINVAL;
queue->mask = bitmap_alloc(PTP_MAX_CHANNELS, GFP_KERNEL);
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 5979758311c8..2ffe404b890f 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -87,7 +87,7 @@ struct dasd_device *dasd_alloc_device(void)
{
struct dasd_device *device;
- device = kzalloc_obj(struct dasd_device, GFP_KERNEL);
+ device = kzalloc_obj(struct dasd_device);
if (!device)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index 61f167e20574..21b7e9666b74 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -767,7 +767,7 @@ static int fnic_nvmef_debugfs_open(struct inode *inode, struct file *file)
struct fnic_nvmef_info *info;
int buf_size = 2 * PAGE_SIZE;
- info = kzalloc_obj(struct fnic_nvmef_info, GFP_KERNEL);
+ info = kzalloc_obj(struct fnic_nvmef_info);
if (!info)
return -ENOMEM;
diff --git a/drivers/scsi/leapraid/leapraid_func.c b/drivers/scsi/leapraid/leapraid_func.c
index 089d0810bd13..66b43c1c72e1 100644
--- a/drivers/scsi/leapraid/leapraid_func.c
+++ b/drivers/scsi/leapraid/leapraid_func.c
@@ -2984,8 +2984,7 @@ static void leapraid_fw_evt_put(struct leapraid_fw_evt_work *fw_work)
static struct leapraid_fw_evt_work *leapraid_alloc_fw_evt_work(void)
{
- struct leapraid_fw_evt_work *fw_evt =
- kzalloc(sizeof(*fw_evt), GFP_ATOMIC);
+ struct leapraid_fw_evt_work *fw_evt = kzalloc_obj(*fw_evt, GFP_ATOMIC);
if (fw_evt)
kref_init(&fw_evt->refcnt);
@@ -3644,8 +3643,7 @@ static void leapraid_sas_host_add(struct leapraid_adapter *adapter,
return;
adapter->dev_topo.card.card_phy =
- kcalloc(phys_num,
- sizeof(struct leapraid_card_phy), GFP_KERNEL);
+ kzalloc_objs(struct leapraid_card_phy, phys_num);
if (!adapter->dev_topo.card.card_phy)
return;
@@ -3763,8 +3761,7 @@ static int leapraid_internal_exp_add(struct leapraid_adapter *adapter,
}
topo_node_exp->card_phy =
- kcalloc(topo_node_exp->phys_num,
- sizeof(struct leapraid_card_phy), GFP_KERNEL);
+ kzalloc_objs(struct leapraid_card_phy, topo_node_exp->phys_num);
if (!topo_node_exp->card_phy) {
dev_err(&adapter->pdev->dev,
"%s: Failed to alloc expander phy array, count=%u\n",
@@ -4352,7 +4349,7 @@ static void leapraid_sas_volume_add(
return;
}
- raid_volume = kzalloc(sizeof(*raid_volume), GFP_KERNEL);
+ raid_volume = kzalloc_obj(*raid_volume);
if (!raid_volume)
return;
@@ -6090,17 +6087,15 @@ static void leapraid_update_card_port_after_reset(
if (!adapter->dev_topo.card.card_phy) {
adapter->dev_topo.card.card_phy =
- kcalloc(nr_phys, sizeof(struct leapraid_card_phy),
- GFP_KERNEL);
+ kzalloc_objs(struct leapraid_card_phy, nr_phys);
if (!adapter->dev_topo.card.card_phy)
return;
}
adapter->dev_topo.card.phys_num = nr_phys;
- new_card_port_table = kcalloc(adapter->dev_topo.card.phys_num,
- sizeof(struct leapraid_card_port),
- GFP_KERNEL);
+ new_card_port_table = kzalloc_objs(struct leapraid_card_port,
+ adapter->dev_topo.card.phys_num);
if (!new_card_port_table)
return;
@@ -7224,8 +7219,8 @@ static int leapraid_set_legacy_int(struct leapraid_adapter *adapter)
adapter->notification_desc.iopoll_qdex,
adapter->notification_desc.iopoll_qcnt);
adapter->notification_desc.int_rqs =
- kcalloc(adapter->notification_desc.iopoll_qdex,
- sizeof(struct leapraid_int_rq), GFP_KERNEL);
+ kzalloc_objs(struct leapraid_int_rq,
+ adapter->notification_desc.iopoll_qdex);
if (!adapter->notification_desc.int_rqs)
return -ENOMEM;
@@ -7268,9 +7263,8 @@ static int leapraid_set_msix(struct leapraid_adapter *adapter)
}
if (iopoll_qcnt) {
adapter->notification_desc.blk_mq_poll_rqs =
- kcalloc(iopoll_qcnt,
- sizeof(struct leapraid_blk_mq_poll_rq),
- GFP_KERNEL);
+ kzalloc_objs(struct leapraid_blk_mq_poll_rq,
+ iopoll_qcnt);
if (!adapter->notification_desc.blk_mq_poll_rqs)
return -ENOMEM;
adapter->adapter_attr.rq_cnt =
@@ -7289,8 +7283,8 @@ static int leapraid_set_msix(struct leapraid_adapter *adapter)
adapter->notification_desc.iopoll_qcnt);
adapter->notification_desc.int_rqs =
- kcalloc(adapter->notification_desc.iopoll_qdex,
- sizeof(struct leapraid_int_rq), GFP_KERNEL);
+ kzalloc_objs(struct leapraid_int_rq,
+ adapter->notification_desc.iopoll_qdex);
if (!adapter->notification_desc.int_rqs)
return -ENOMEM;
@@ -7365,9 +7359,8 @@ static int leapraid_set_msi(struct leapraid_adapter *adapter)
if (iopoll_qcnt) {
adapter->notification_desc.blk_mq_poll_rqs =
- kcalloc(iopoll_qcnt,
- sizeof(struct leapraid_blk_mq_poll_rq),
- GFP_KERNEL);
+ kzalloc_objs(struct leapraid_blk_mq_poll_rq,
+ iopoll_qcnt);
if (!adapter->notification_desc.blk_mq_poll_rqs)
return -ENOMEM;
@@ -7404,9 +7397,8 @@ static int leapraid_set_msi(struct leapraid_adapter *adapter)
adapter->notification_desc.iopoll_qcnt);
adapter->notification_desc.int_rqs =
- kcalloc(adapter->notification_desc.iopoll_qdex,
- sizeof(struct leapraid_int_rq),
- GFP_KERNEL);
+ kzalloc_objs(struct leapraid_int_rq,
+ adapter->notification_desc.iopoll_qdex);
if (!adapter->notification_desc.int_rqs)
return -ENOMEM;
@@ -7958,18 +7950,16 @@ static int leapraid_request_host_memory(struct leapraid_adapter *adapter)
DIV_ROUND_UP(adapter->adapter_attr.rq_cnt,
LEAPRAID_REP_DESC_CHUNK_SIZE);
adapter->mem_desc.rep_desc_seg_maint =
- kcalloc(adapter->adapter_attr.rep_desc_q_seg_cnt,
- sizeof(struct leapraid_rep_desc_seg_maint),
- GFP_KERNEL);
+ kzalloc_objs(struct leapraid_rep_desc_seg_maint,
+ adapter->adapter_attr.rep_desc_q_seg_cnt);
if (!adapter->mem_desc.rep_desc_seg_maint)
return -ENOMEM;
rep_desc_q_cnt_allocated = 0;
for (i = 0; i < adapter->adapter_attr.rep_desc_q_seg_cnt; i++) {
adapter->mem_desc.rep_desc_seg_maint[i].rep_desc_maint =
- kcalloc(LEAPRAID_REP_DESC_CHUNK_SIZE,
- sizeof(struct leapraid_rep_desc_maint),
- GFP_KERNEL);
+ kzalloc_objs(struct leapraid_rep_desc_maint,
+ LEAPRAID_REP_DESC_CHUNK_SIZE);
if (!adapter->mem_desc.rep_desc_seg_maint[i].rep_desc_maint)
return -ENOMEM;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 3b82e80e807a..0f0f243c2561 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -158,7 +158,7 @@ int scsi_complete_async_scans(void)
* sleep a little. Even if we never get memory, the async
* scans will finish eventually.
*/
- data = kmalloc(sizeof(*data), GFP_KERNEL);
+ data = kmalloc_obj(*data);
if (!data)
msleep(1);
} while (!data);
diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c
index 7be0374f5943..a903fa44e4e5 100644
--- a/drivers/soc/bcm/brcmstb/common.c
+++ b/drivers/soc/bcm/brcmstb/common.c
@@ -65,7 +65,7 @@ static int __init brcmstb_soc_device_init(void)
goto out_put_node;
}
- soc_info = kzalloc(sizeof(*soc_info), GFP_KERNEL);
+ soc_info = kzalloc_obj(*soc_info);
if (!soc_info) {
ret = -ENOMEM;
goto out_unmap;
diff --git a/drivers/spi/spi-offload.c b/drivers/spi/spi-offload.c
index a579ef33b2d2..a446927a51d3 100644
--- a/drivers/spi/spi-offload.c
+++ b/drivers/spi/spi-offload.c
@@ -434,7 +434,7 @@ int devm_spi_offload_trigger_register(struct device *dev,
if (!info->fwnode || !info->ops || !info->ops->match)
return -EINVAL;
- trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
+ trigger = kzalloc_obj(*trigger);
if (!trigger)
return -ENOMEM;
diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c
index 459aed0f1240..4f1b3f4db404 100644
--- a/drivers/staging/greybus/raw.c
+++ b/drivers/staging/greybus/raw.c
@@ -178,7 +178,7 @@ static int gb_raw_probe(struct gb_bundle *bundle,
if (minor < 0)
return minor;
- raw = kzalloc_obj(*raw, GFP_KERNEL);
+ raw = kzalloc_obj(*raw);
if (!raw) {
ida_free(&minors, minor);
return -ENOMEM;
diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c
index 00082276f1db..4a182dc384ca 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -5820,36 +5820,31 @@ static int ia_css_pipe_create_cas_scaler_desc_single_output(
}
descr->in_info = kmalloc_objs(*descr->in_info,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->in_info) {
err = -ENOMEM;
goto ERR;
}
descr->internal_out_info = kmalloc_objs(*descr->internal_out_info,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->internal_out_info) {
err = -ENOMEM;
goto ERR;
}
descr->out_info = kmalloc_objs(*descr->out_info,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->out_info) {
err = -ENOMEM;
goto ERR;
}
descr->vf_info = kmalloc_objs(*descr->vf_info,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->vf_info) {
err = -ENOMEM;
goto ERR;
}
descr->is_output_stage = kmalloc_objs(*descr->is_output_stage,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->is_output_stage) {
err = -ENOMEM;
goto ERR;
@@ -5970,36 +5965,31 @@ ia_css_pipe_create_cas_scaler_desc(struct ia_css_pipe *pipe,
descr->num_stage = num_stages;
descr->in_info = kmalloc_objs(*descr->in_info,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->in_info) {
err = -ENOMEM;
goto ERR;
}
descr->internal_out_info = kmalloc_objs(*descr->internal_out_info,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->internal_out_info) {
err = -ENOMEM;
goto ERR;
}
descr->out_info = kmalloc_objs(*descr->out_info,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->out_info) {
err = -ENOMEM;
goto ERR;
}
descr->vf_info = kmalloc_objs(*descr->vf_info,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->vf_info) {
err = -ENOMEM;
goto ERR;
}
descr->is_output_stage = kmalloc_objs(*descr->is_output_stage,
- descr->num_stage,
- GFP_KERNEL);
+ descr->num_stage);
if (!descr->is_output_stage) {
err = -ENOMEM;
goto ERR;
diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index af12df2f9b09..b895dee77568 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -254,8 +254,8 @@ sh_css_load_firmware(struct device *dev, const char *fw_data,
/* Only allocate memory for ISP blob info */
if (sh_css_num_binaries > NUM_OF_SPS) {
sh_css_blob_info =
- kmalloc_array(sh_css_num_binaries - NUM_OF_SPS,
- sizeof(*sh_css_blob_info), GFP_KERNEL);
+ kmalloc_objs(*sh_css_blob_info,
+ sh_css_num_binaries - NUM_OF_SPS);
if (!sh_css_blob_info)
return -ENOMEM;
} else {
diff --git a/drivers/tee/qcomtee/user_obj.c b/drivers/tee/qcomtee/user_obj.c
index 10452fcc7ccb..a06eb94e0bae 100644
--- a/drivers/tee/qcomtee/user_obj.c
+++ b/drivers/tee/qcomtee/user_obj.c
@@ -230,8 +230,7 @@ static int qcomtee_user_object_dispatch(struct qcomtee_object_invoke_ctx *oic,
struct qcomtee_context_data *ctxdata = uo->ctx->data;
int errno;
- struct qcomtee_ureq *ureq __free(kfree) = kzalloc(sizeof(*ureq),
- GFP_KERNEL);
+ struct qcomtee_ureq *ureq __free(kfree) = kzalloc_obj(*ureq);
if (!ureq)
return -ENOMEM;
diff --git a/drivers/thunderbolt/stream.c b/drivers/thunderbolt/stream.c
index c737dd0ca6e7..25c259dd0760 100644
--- a/drivers/thunderbolt/stream.c
+++ b/drivers/thunderbolt/stream.c
@@ -408,8 +408,7 @@ static int tbstream_dev_alloc_rx_buffers(struct tbstream_dev *sdev)
size_t ring_size = tb_ring_size(sdev->rx_ring.ring);
int i;
- sdev->rx_ring.frames = kcalloc(ring_size, sizeof(struct tbstream_frame),
- GFP_KERNEL);
+ sdev->rx_ring.frames = kzalloc_objs(struct tbstream_frame, ring_size);
if (!sdev->rx_ring.frames)
return -ENOMEM;
@@ -463,8 +462,7 @@ static int tbstream_dev_alloc_tx_buffers(struct tbstream_dev *sdev)
size_t ring_size = tb_ring_size(sdev->tx_ring.ring);
int i;
- sdev->tx_ring.frames = kcalloc(ring_size, sizeof(struct tbstream_frame),
- GFP_KERNEL);
+ sdev->tx_ring.frames = kzalloc_objs(struct tbstream_frame, ring_size);
if (!sdev->tx_ring.frames)
return -ENOMEM;
@@ -1498,7 +1496,7 @@ tbstream_dev_make_group(struct config_group *group, const char *name)
if (strlen(name) > TB_PROPERTY_KEY_SIZE)
return ERR_PTR(-ENAMETOOLONG);
- sdev = kzalloc_obj(*sdev, GFP_KERNEL);
+ sdev = kzalloc_obj(*sdev);
if (!sdev)
return ERR_PTR(-ENOMEM);
@@ -1592,7 +1590,7 @@ tbstream_make_group(struct config_group *group, const char *name)
if (sscanf(name, "%u-%llx.%u", &domain, &route, &index) != 3)
return ERR_PTR(-EINVAL);
- sg = kzalloc_obj(*sg, GFP_KERNEL);
+ sg = kzalloc_obj(*sg);
if (!sg)
return ERR_PTR(-ENOMEM);
@@ -1698,7 +1696,7 @@ static int tbstream_probe(struct tb_service *svc)
{
struct tbstream *stream;
- stream = kzalloc_obj(*stream, GFP_KERNEL);
+ stream = kzalloc_obj(*stream);
if (!stream)
return -ENOMEM;
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index 1bb2376af85c..40a1c614e23b 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -954,8 +954,7 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
unsigned int i, first_idx;
int ret;
- brd->ports = kcalloc(MAX_PORTS_PER_BOARD, sizeof(*brd->ports),
- GFP_KERNEL);
+ brd->ports = kzalloc_objs(*brd->ports, MAX_PORTS_PER_BOARD);
if (brd->ports == NULL) {
printk(KERN_ERR "cannot allocate memory for ports\n");
ret = -ENOMEM;
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index 3fa89a2dbeba..7d564341a7eb 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -776,7 +776,8 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct,
struct uni_pagedict *dict;
unsigned int d, r, g;
- struct unipair *unilist __free(kvfree) = kvmalloc_array(ct, sizeof(*unilist), GFP_KERNEL);
+ struct unipair *unilist __free(kvfree) = kvmalloc_objs(*unilist, ct,
+ GFP_KERNEL);
if (!unilist)
return -ENOMEM;
diff --git a/drivers/ufs/core/ufs-txeq.c b/drivers/ufs/core/ufs-txeq.c
index fa5f539632eb..6192512e29de 100644
--- a/drivers/ufs/core/ufs-txeq.c
+++ b/drivers/ufs/core/ufs-txeq.c
@@ -1073,7 +1073,7 @@ static int __ufshcd_tx_eqtr(struct ufs_hba *hba,
struct ufs_pa_layer_attr *pwr_mode)
{
struct ufshcd_tx_eqtr_data *eqtr_data __free(kfree) =
- kzalloc(sizeof(*eqtr_data), GFP_KERNEL);
+ kzalloc_obj(*eqtr_data);
struct tx_eqtr_iter h_iter = {};
struct tx_eqtr_iter d_iter = {};
u32 gear = pwr_mode->gear_tx;
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 62396212a0a7..65c0816bc675 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -2761,7 +2761,7 @@ static int ufs_qcom_get_rx_fom(struct ufs_hba *hba,
struct tx_eqtr_iter *d_iter)
{
struct ufshcd_tx_eq_params *params __free(kfree) =
- kzalloc(sizeof(*params), GFP_KERNEL);
+ kzalloc_obj(*params);
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct ufs_pa_layer_attr old_pwr_info;
u32 fom[PA_MAXDATALANES] = { 0 };
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index bf02545b37a2..500c9c19c78b 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -1766,7 +1766,7 @@ static struct usb_function *ncm_alloc(struct usb_function_instance *fi)
int status;
/* allocate and initialize one new instance */
- ncm = kzalloc(sizeof(*ncm), GFP_KERNEL);
+ ncm = kzalloc_obj(*ncm);
if (!ncm)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
index a5837c0feb05..100f8920624b 100644
--- a/drivers/usb/usbip/usbip_common.c
+++ b/drivers/usb/usbip/usbip_common.c
@@ -696,7 +696,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
size = np * sizeof(*iso);
- buff = kcalloc(np, sizeof(*iso), GFP_KERNEL);
+ buff = kzalloc_objs(*iso, np);
if (!buff)
return -ENOMEM;
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 69922be28b54..076c1b0ab87f 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -1478,7 +1478,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
/* No need for kzalloc as it is initialized in following hypercall
* GNTTABOP_setup_table.
*/
- frames = kmalloc_array(nr_gframes, sizeof(*frames), GFP_ATOMIC);
+ frames = kmalloc_objs(*frames, nr_gframes, GFP_ATOMIC);
if (!frames)
return -ENOMEM;
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c
index e549e222602e..fa6b7143db98 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -113,8 +113,7 @@ void v9fs_dentry_fid_remove(struct dentry *dentry)
*/
static int v9fs_dentry_init(struct dentry *dentry)
{
- struct v9fs_dentry *v9fs_dentry = kzalloc(sizeof(*v9fs_dentry),
- GFP_KERNEL);
+ struct v9fs_dentry *v9fs_dentry = kzalloc_obj(*v9fs_dentry);
if (!v9fs_dentry)
return -ENOMEM;
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 81565366d937..2db534a2c7cc 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -1801,7 +1801,7 @@ static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
goto error;
ret = -ENOMEM;
- symlink = kmalloc_flex(struct afs_symlink, content, clen + 1, GFP_KERNEL);
+ symlink = kmalloc_flex(struct afs_symlink, content, clen + 1);
if (!symlink)
goto error;
refcount_set(&symlink->ref, 1);
diff --git a/fs/afs/symlink.c b/fs/afs/symlink.c
index 16b4823cb7b7..6b8c122877ca 100644
--- a/fs/afs/symlink.c
+++ b/fs/afs/symlink.c
@@ -119,8 +119,7 @@ static ssize_t afs_do_read_symlink(struct afs_vnode *vnode)
vnode->directory_size = i_size;
/* Copy the symlink. */
- symlink = kmalloc_flex(struct afs_symlink, content, i_size + 1,
- GFP_KERNEL);
+ symlink = kmalloc_flex(struct afs_symlink, content, i_size + 1);
if (!symlink)
return -ENOMEM;
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index ddfd3aa57ac8..620da85948b4 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -331,8 +331,8 @@ static int entry_attach_interpreter(struct binfmt_misc_entry *e,
return -ENOSPC;
/* One allocation, both strings in it, like the entry's own buffer. */
- interp = kmalloc(struct_size(interp, name, nlen + plen + 2),
- GFP_KERNEL_ACCOUNT);
+ interp = kmalloc_flex(*interp, name, nlen + plen + 2,
+ GFP_KERNEL_ACCOUNT);
if (!interp) {
dec_ucount(ucounts, UCOUNT_BINFMT_MISC_INTERPRETERS);
return -ENOMEM;
@@ -858,8 +858,7 @@ static struct binfmt_misc_entry *create_entry(const char __user *buffer,
if ((count < 11) || (count > MAX_REGISTER_LENGTH))
return ERR_PTR(-EINVAL);
- e = kmalloc(struct_size(e, buf, count + MISC_DELIM_PAD),
- GFP_KERNEL_ACCOUNT);
+ e = kmalloc_flex(*e, buf, count + MISC_DELIM_PAD, GFP_KERNEL_ACCOUNT);
if (!e)
return ERR_PTR(-ENOMEM);
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 657c2cb0f881..e598b2d424ec 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -2546,7 +2546,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci,
}
pool_ns_len = pool_ns ? pool_ns->len : 0;
- perm = kmalloc_flex(*perm, pool_ns, pool_ns_len + 1, GFP_KERNEL);
+ perm = kmalloc_flex(*perm, pool_ns, pool_ns_len + 1);
if (!perm) {
err = -ENOMEM;
goto out_unlock;
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index a091f77cedaf..cc5fea0a9012 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -5492,7 +5492,7 @@ static void ceph_mdsc_reset_workfn(struct work_struct *work)
goto out_complete;
}
- sessions = kcalloc(max_sessions, sizeof(*sessions), GFP_KERNEL);
+ sessions = kzalloc_objs(*sessions, max_sessions);
if (!sessions) {
mutex_unlock(&mdsc->mutex);
ret = -ENOMEM;
diff --git a/fs/ceph/subvolume_metrics.c b/fs/ceph/subvolume_metrics.c
index 03fda1f9257b..01419c9482f1 100644
--- a/fs/ceph/subvolume_metrics.c
+++ b/fs/ceph/subvolume_metrics.c
@@ -245,7 +245,7 @@ int ceph_subvolume_metrics_snapshot(struct ceph_subvolume_metrics_tracker *track
return 0;
}
- snap = kcalloc(count, sizeof(*snap), GFP_NOFS);
+ snap = kzalloc_objs(*snap, count, GFP_NOFS);
if (!snap) {
atomic64_inc(&tracker->snapshot_failures);
return -ENOMEM;
diff --git a/fs/coredump.c b/fs/coredump.c
index ac3cd74808c6..6114839f5178 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1000,7 +1000,7 @@ static bool coredump_pipe(struct core_name *cn, struct coredump_params *cprm,
return false;
}
- helper_argv = kmalloc_array(argc + 1, sizeof(*helper_argv), GFP_KERNEL);
+ helper_argv = kmalloc_objs(*helper_argv, argc + 1);
if (!helper_argv) {
coredump_report_failure("%s failed to allocate memory", __func__);
return false;
diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
index 062103e42cd8..0cac890cf370 100644
--- a/fs/ext4/fast_commit.c
+++ b/fs/ext4/fast_commit.c
@@ -1116,7 +1116,7 @@ static int ext4_fc_snapshot_inode(struct inode *inode,
else if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE)
inode_len += ei->i_extra_isize;
- snap = kmalloc(struct_size(snap, inode_buf, inode_len), GFP_NOFS);
+ snap = kmalloc_flex(*snap, inode_buf, inode_len, GFP_NOFS);
if (!snap) {
atomic64_inc(&stats->snap_fail_nomem);
ext4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_NOMEM);
@@ -1522,7 +1522,7 @@ static int ext4_fc_alloc_snapshot_inodes(struct super_block *sb,
if (nr_inodes > EXT4_FC_SNAPSHOT_MAX_INODES)
return -E2BIG;
- inodes = kvcalloc(nr_inodes, sizeof(*inodes), GFP_NOFS);
+ inodes = kvzalloc_objs(*inodes, nr_inodes, GFP_NOFS);
if (!inodes)
return -ENOMEM;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 8d6135a6108a..9a36d0329e22 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1597,8 +1597,7 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
* manually extract pages using iov_iter_extract_pages() and then
* copy that to a folios array.
*/
- struct page **pages = kcalloc(max_pages, sizeof(struct page *),
- GFP_KERNEL);
+ struct page **pages = kzalloc_objs(struct page *, max_pages);
if (!pages) {
ret = -ENOMEM;
goto out;
diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c
index 5ca87151d70d..d2599043f7ec 100644
--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -336,7 +336,7 @@ static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file,
static struct page **fuse_readdir_alloc_buf(struct fuse_args_pages *ap, size_t *bufsize)
{
unsigned int i, nr_alloc, nr_pages = DIV_ROUND_UP(*bufsize, PAGE_SIZE);
- struct page **pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
+ struct page **pages = kzalloc_objs(*pages, nr_pages);
if (!pages)
return NULL;
diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index 1b331108d9c0..fcb5b9cd17f6 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -312,7 +312,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
return NULL;
}
- node = kzalloc_flex(*node, page, tree->pages_per_bnode, GFP_KERNEL);
+ node = kzalloc_flex(*node, page, tree->pages_per_bnode);
if (!node)
return NULL;
node->tree = tree;
diff --git a/fs/namespace.c b/fs/namespace.c
index 1ecd96c918b3..ae5dc64f8b45 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -5999,7 +5999,7 @@ SYSCALL_DEFINE4(statmount, const struct mnt_id_req __user *, req,
return -EPERM;
}
- ks = kmalloc(sizeof(*ks), GFP_KERNEL_ACCOUNT);
+ ks = kmalloc_obj(*ks, GFP_KERNEL_ACCOUNT);
if (!ks)
return -ENOMEM;
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index a47c90f40422..a7ebce53faec 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -358,7 +358,7 @@ int nfsd_nl_expkey_get_reqs_dumpit(struct sk_buff *skb,
goto out_unlock;
}
- items = kcalloc(cnt, sizeof(*items), GFP_KERNEL);
+ items = kzalloc_objs(*items, cnt);
seqnos = kcalloc(cnt, sizeof(*seqnos), GFP_KERNEL);
if (!items || !seqnos) {
ret = -ENOMEM;
@@ -685,7 +685,7 @@ int nfsd_nl_svc_export_get_reqs_dumpit(struct sk_buff *skb,
goto out_unlock;
}
- items = kcalloc(cnt, sizeof(*items), GFP_KERNEL);
+ items = kzalloc_objs(*items, cnt);
seqnos = kcalloc(cnt, sizeof(*seqnos), GFP_KERNEL);
pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
if (!items || !seqnos || !pathbuf) {
@@ -786,8 +786,7 @@ static int nfsd_nl_parse_fslocations(struct nlattr *attr,
if (!count)
return 0;
- fsloc->locations = kcalloc(count, sizeof(struct nfsd4_fs_location),
- GFP_KERNEL);
+ fsloc->locations = kzalloc_objs(struct nfsd4_fs_location, count);
if (!fsloc->locations)
return -ENOMEM;
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index a901bbe67e03..19dc337502ca 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -1981,12 +1981,12 @@ int nfsd_net_cb_init(struct nfsd_net *nn)
{
struct nfsd_net_cb *cb;
- cb = kzalloc(sizeof(*cb), GFP_KERNEL);
+ cb = kzalloc_obj(*cb);
if (!cb)
return -ENOMEM;
cb->version4.counts = kzalloc_objs(unsigned int,
- ARRAY_SIZE(nfs4_cb_procedures), GFP_KERNEL);
+ ARRAY_SIZE(nfs4_cb_procedures));
if (!cb->version4.counts) {
kfree(cb);
return -ENOMEM;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 18e17232cf94..9c4adf3110ae 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1341,7 +1341,7 @@ alloc_init_dir_deleg(struct nfs4_client *clp, struct nfs4_file *fp)
return NULL;
}
- ncn->ncn_nf = kcalloc(NOTIFY4_EVENT_QUEUE_SIZE, sizeof(*ncn->ncn_nf), GFP_KERNEL);
+ ncn->ncn_nf = kzalloc_objs(*ncn->ncn_nf, NOTIFY4_EVENT_QUEUE_SIZE);
if (!ncn->ncn_nf) {
nfs4_put_stid(&dp->dl_stid);
return NULL;
@@ -10419,8 +10419,9 @@ alloc_nfsd_notify_event(u32 mask, const struct qstr *q, struct dentry *dentry,
newnamelen = newname.name.len;
}
- ne = kmalloc(struct_size(ne, ne_name, q->len + 1 +
- (newnamelen ? newnamelen + 1 : 0)), GFP_NOFS);
+ ne = kmalloc_flex(*ne, ne_name,
+ q->len + 1 + (newnamelen ? newnamelen + 1 : 0),
+ GFP_NOFS);
if (!ne)
goto out;
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index adb032b7311a..5abb2d4274c9 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -1647,7 +1647,7 @@ static int nfsd_nl_fh_key_set(const struct nlattr *attr, struct nfsd_net *nn)
k1 = get_unaligned_le64(nla_data(attr) + 8);
if (!fh_key) {
- fh_key = kmalloc(sizeof(siphash_key_t), GFP_KERNEL);
+ fh_key = kmalloc_obj(siphash_key_t);
if (!fh_key) {
trace_nfsd_ctl_fh_key_set(false, -ENOMEM);
return -ENOMEM;
diff --git a/fs/ntfs/bitmap.c b/fs/ntfs/bitmap.c
index 1840b7d84c62..5a4457551306 100644
--- a/fs/ntfs/bitmap.c
+++ b/fs/ntfs/bitmap.c
@@ -40,7 +40,7 @@ int ntfs_trim_fs(struct ntfs_volume *vol, struct fstrim_range *range)
end_cluster = vol->nr_clusters;
}
- ra = kzalloc(sizeof(*ra), GFP_NOFS);
+ ra = kzalloc_obj(*ra, GFP_NOFS);
if (!ra)
return -ENOMEM;
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index 197d8607fc63..99a3ea2b5c55 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -514,8 +514,8 @@ int ntfs_read_compressed_block(struct folio *folio)
return -EIO;
}
- pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_NOFS);
- completed_pages = kmalloc_array(nr_pages + 1, sizeof(int), GFP_NOFS);
+ pages = kmalloc_objs(struct page *, nr_pages, GFP_NOFS);
+ completed_pages = kmalloc_objs(int, nr_pages + 1, GFP_NOFS);
if (unlikely(!pages || !completed_pages)) {
kfree(pages);
@@ -1262,7 +1262,7 @@ static int ntfs_compress_workspace_init(struct ntfs_inode *ni,
size = ni->itype.compressed.block_size + 2 *
(ni->itype.compressed.block_size / NTFS_SB_SIZE) + 2;
ws->nr_pages = DIV_ROUND_UP(size, PAGE_SIZE);
- ws->pages = kcalloc(ws->nr_pages, sizeof(*ws->pages), GFP_NOFS);
+ ws->pages = kzalloc_objs(*ws->pages, ws->nr_pages, GFP_NOFS);
if (!ws->pages)
return -ENOMEM;
@@ -1483,7 +1483,7 @@ int ntfs_compress_write(struct ntfs_inode *ni, loff_t pos, size_t count,
pages_per_cb = DIV_ROUND_UP(offset_in_page(pos & ~(cb_size - 1)) +
cb_size, PAGE_SIZE);
- pages = kmalloc_array(pages_per_cb, sizeof(struct page *), GFP_NOFS);
+ pages = kmalloc_objs(struct page *, pages_per_cb, GFP_NOFS);
if (!pages)
return -ENOMEM;
ctx = kvzalloc_obj(*ctx, GFP_NOFS);
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 2d594cbb4ebe..df60138f9b2d 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -166,8 +166,8 @@ u64 ntfs_lookup_inode_by_name(struct ntfs_inode *dir_ni, const __le16 *uname,
*/
if (ie->key.file_name.file_name_type == FILE_NAME_DOS) {
if (!name) {
- name = kmalloc(sizeof(struct ntfs_name),
- GFP_NOFS);
+ name = kmalloc_obj(struct ntfs_name,
+ GFP_NOFS);
if (!name) {
err = -ENOMEM;
goto err_out;
@@ -401,8 +401,8 @@ u64 ntfs_lookup_inode_by_name(struct ntfs_inode *dir_ni, const __le16 *uname,
*/
if (ie->key.file_name.file_name_type == FILE_NAME_DOS) {
if (!name) {
- name = kmalloc(sizeof(struct ntfs_name),
- GFP_NOFS);
+ name = kmalloc_obj(struct ntfs_name,
+ GFP_NOFS);
if (!name) {
err = -ENOMEM;
goto unm_err_out;
@@ -700,7 +700,7 @@ static int ntfs_ia_blocks_readahead(struct ntfs_inode *ia_ni, loff_t pos)
if (dir_start_index >= dir_end_index)
return 0;
- dir_ra = kzalloc(sizeof(*dir_ra), GFP_NOFS);
+ dir_ra = kzalloc_obj(*dir_ra, GFP_NOFS);
if (!dir_ra)
return -ENOMEM;
@@ -777,7 +777,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
return -ENOMEM;
}
- ra = kzalloc(sizeof(struct file_ra_state), GFP_NOFS);
+ ra = kzalloc_obj(struct file_ra_state, GFP_NOFS);
if (!ra) {
kfree(name);
ntfs_index_ctx_put(ictx);
@@ -813,7 +813,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
goto out;
}
} else if (!private) {
- private = kzalloc(sizeof(struct ntfs_file_private), GFP_KERNEL);
+ private = kzalloc_obj(struct ntfs_file_private);
if (!private) {
err = -ENOMEM;
goto out;
@@ -949,7 +949,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
}
if (!nir) {
- nir = kzalloc(sizeof(struct ntfs_index_ra), GFP_KERNEL);
+ nir = kzalloc_obj(struct ntfs_index_ra);
if (nir) {
nir->start_index = index;
nir->count = 1;
diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index 3f4ba7667522..b4fcfbe2da4c 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -235,7 +235,7 @@ static int ntfs_set_ea(struct inode *inode, const char *name, size_t name_len,
ea_info_qsize = le32_to_cpu(p_ea_info->ea_query_length);
} else {
create_ea_info:
- p_ea_info = kzalloc(sizeof(struct ea_information), GFP_NOFS);
+ p_ea_info = kzalloc_obj(struct ea_information, GFP_NOFS);
if (!p_ea_info)
return -ENOMEM;
diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c
index 46a8b19c0723..580998990bc9 100644
--- a/fs/ntfs/index.c
+++ b/fs/ntfs/index.c
@@ -1660,7 +1660,7 @@ static int ntfs_ib_split(struct ntfs_index_context *icx, struct index_block *ib)
goto out;
}
} else {
- si = kzalloc(sizeof(struct split_info), GFP_NOFS);
+ si = kzalloc_obj(struct split_info, GFP_NOFS);
if (!si) {
ntfs_ibm_clear(icx, new_vcn);
ret = -ENOMEM;
diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
index 024ddee42dc8..1404664dacc0 100644
--- a/fs/ntfs/logfile.c
+++ b/fs/ntfs/logfile.c
@@ -691,7 +691,7 @@ bool ntfs_empty_logfile(struct inode *log_vi)
memset(empty_buf, 0xff, vol->cluster_size);
- ra = kzalloc(sizeof(*ra), GFP_NOFS);
+ ra = kzalloc_obj(*ra, GFP_NOFS);
if (!ra)
goto err;
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 7e58c99f1728..98ab686a5ea2 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -2635,11 +2635,13 @@ static int ntfs_write_mft_block(struct folio *folio, struct writeback_control *w
struct ntfs_inode *ni = NTFS_I(vi);
struct ntfs_volume *vol = ni->vol;
u8 *kaddr;
- struct ntfs_inode **locked_nis __free(kfree) = kmalloc_array(PAGE_SIZE / NTFS_BLOCK_SIZE,
- sizeof(struct ntfs_inode *), GFP_NOFS);
+ struct ntfs_inode **locked_nis __free(kfree) = kmalloc_objs(struct ntfs_inode *,
+ PAGE_SIZE / NTFS_BLOCK_SIZE,
+ GFP_NOFS);
int nr_locked_nis = 0, err = 0, mft_ofs, prev_mft_ofs;
- struct inode **ref_inos __free(kfree) = kmalloc_array(PAGE_SIZE / NTFS_BLOCK_SIZE,
- sizeof(struct inode *), GFP_NOFS);
+ struct inode **ref_inos __free(kfree) = kmalloc_objs(struct inode *,
+ PAGE_SIZE / NTFS_BLOCK_SIZE,
+ GFP_NOFS);
int nr_ref_inos = 0;
struct bio *bio = NULL;
u64 mft_no;
diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c
index 00373e450ea7..3a61f19bcbee 100644
--- a/fs/ntfs/runlist.c
+++ b/fs/ntfs/runlist.c
@@ -1804,7 +1804,7 @@ struct runlist_element *ntfs_rl_insert_range(struct runlist_element *dst_rl, int
new_2nd_cnt = src_cnt;
new_cnt = new_1st_cnt + new_2nd_cnt + new_3rd_cnt;
new_cnt += dst_rl_split.lcn >= LCN_HOLE ? 1 : 0;
- new_rl = kvcalloc(new_cnt, sizeof(*new_rl), GFP_NOFS);
+ new_rl = kvzalloc_objs(*new_rl, new_cnt, GFP_NOFS);
if (!new_rl)
return ERR_PTR(-ENOMEM);
@@ -1888,13 +1888,13 @@ struct runlist_element *ntfs_rl_punch_hole(struct runlist_element *dst_rl, int d
punch_cnt = (int)(e_rl - s_rl) + 1;
- *punch_rl = kvcalloc(punch_cnt + 1, sizeof(struct runlist_element),
- GFP_NOFS);
+ *punch_rl = kvzalloc_objs(struct runlist_element, punch_cnt + 1,
+ GFP_NOFS);
if (!*punch_rl)
return ERR_PTR(-ENOMEM);
new_cnt = dst_cnt - (int)(e_rl - s_rl + 1) + 3;
- new_rl = kvcalloc(new_cnt, sizeof(struct runlist_element), GFP_NOFS);
+ new_rl = kvzalloc_objs(struct runlist_element, new_cnt, GFP_NOFS);
if (!new_rl) {
kvfree(*punch_rl);
*punch_rl = NULL;
@@ -2038,13 +2038,13 @@ struct runlist_element *ntfs_rl_collapse_range(struct runlist_element *dst_rl, i
one_split_3 = e_rl == s_rl && begin_split && end_split;
punch_cnt = (int)(e_rl - s_rl) + 1;
- *punch_rl = kvcalloc(punch_cnt + 1, sizeof(struct runlist_element),
- GFP_NOFS);
+ *punch_rl = kvzalloc_objs(struct runlist_element, punch_cnt + 1,
+ GFP_NOFS);
if (!*punch_rl)
return ERR_PTR(-ENOMEM);
new_cnt = dst_cnt - (int)(e_rl - s_rl + 1) + 3;
- new_rl = kvcalloc(new_cnt, sizeof(struct runlist_element), GFP_NOFS);
+ new_rl = kvzalloc_objs(struct runlist_element, new_cnt, GFP_NOFS);
if (!new_rl) {
kvfree(*punch_rl);
*punch_rl = NULL;
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 60d43339c590..5aad2d2a36bb 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -2539,7 +2539,7 @@ static int ntfs_init_fs_context(struct fs_context *fc)
struct ntfs_volume *vol;
/* Allocate a new struct ntfs_volume and place it in sb->s_fs_info. */
- vol = kmalloc(sizeof(struct ntfs_volume), GFP_NOFS);
+ vol = kmalloc_obj(struct ntfs_volume, GFP_NOFS);
if (!vol)
return -ENOMEM;
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index e7fe29cb6028..7d6f7f6022eb 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -1044,7 +1044,7 @@ static int ovl_dir_open(struct inode *inode, struct file *file)
struct ovl_dir_file *od;
enum ovl_path_type type;
- od = kzalloc(sizeof(struct ovl_dir_file), GFP_KERNEL);
+ od = kzalloc_obj(struct ovl_dir_file);
if (!od)
return -ENOMEM;
diff --git a/fs/smb/client/cifs_swn.c b/fs/smb/client/cifs_swn.c
index fe10719e627e..c49ecddf4a33 100644
--- a/fs/smb/client/cifs_swn.c
+++ b/fs/smb/client/cifs_swn.c
@@ -443,7 +443,7 @@ static struct cifs_swn_reg *cifs_get_swn_reg(struct cifs_tcon *tcon)
goto unlock;
}
- reg = kmalloc_obj(struct cifs_swn_reg, GFP_KERNEL);
+ reg = kmalloc_obj(struct cifs_swn_reg);
if (reg == NULL) {
ret = -ENOMEM;
goto fail_unlock;
diff --git a/fs/smb/client/dfs_cache.c b/fs/smb/client/dfs_cache.c
index 86dba25b7a5a..f6c4259479c5 100644
--- a/fs/smb/client/dfs_cache.c
+++ b/fs/smb/client/dfs_cache.c
@@ -365,7 +365,7 @@ static struct cache_dfs_tgt *alloc_target(const char *name, int path_consumed)
{
struct cache_dfs_tgt *t;
- t = kmalloc_obj(*t, GFP_KERNEL);
+ t = kmalloc_obj(*t);
if (!t)
return ERR_PTR(-ENOMEM);
t->name = kstrdup(name, GFP_KERNEL);
diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index 98ea5c6c34af..96063e355186 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -237,7 +237,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
num_rqst = 0;
server = cifs_pick_channel(ses);
- vars = kzalloc_obj(*vars, GFP_KERNEL);
+ vars = kzalloc_obj(*vars);
if (vars == NULL) {
rc = -ENOMEM;
goto out;
diff --git a/fs/smb/server/ksmbd_work.c b/fs/smb/server/ksmbd_work.c
index f35335307670..d307aefe0aec 100644
--- a/fs/smb/server/ksmbd_work.c
+++ b/fs/smb/server/ksmbd_work.c
@@ -30,7 +30,7 @@ static int ksmbd_reserve_iov(struct ksmbd_work *work, int need_iov_cnt)
} while (new_alloc_cnt < work->iov_cnt + need_iov_cnt);
if (work->iov == work->iov_inline) {
- new = kcalloc(new_alloc_cnt, sizeof(*new), KSMBD_DEFAULT_GFP);
+ new = kzalloc_objs(*new, new_alloc_cnt, KSMBD_DEFAULT_GFP);
if (!new)
return -ENOMEM;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 0ecc52fde69c..b7ce67094626 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -11820,7 +11820,7 @@ static void smb2_notify_cancel_fn(void **argv)
return;
conn = in_work->conn;
- ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
+ ctx = kmalloc_obj(*ctx, GFP_ATOMIC);
if (!ctx) {
/* Can't defer the response -- free without sending one. */
list_del_init(&in_work->async_request_entry);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index f190c088591b..7938d2324e87 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2746,8 +2746,8 @@ xfs_dabuf_map(
* larger one that needs to be free by the caller.
*/
if (nirecs > 1) {
- map = kcalloc(nirecs, sizeof(struct xfs_buf_map),
- GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
+ map = kzalloc_objs(struct xfs_buf_map, nirecs,
+ GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
*mapp = map;
}
diff --git a/init/initramfs_test.c b/init/initramfs_test.c
index 9cf316c13ffa..1154547721ea 100644
--- a/init/initramfs_test.c
+++ b/init/initramfs_test.c
@@ -514,7 +514,7 @@ static void __init initramfs_test_hdr_hex(struct kunit *test)
char fdata[] = "this file data will not be unpacked";
struct initramfs_test_bufs {
char cpio_src[(CPIO_HDRLEN + PATH_MAX + 3 + sizeof(fdata)) * 2];
- } *tbufs = kzalloc(sizeof(struct initramfs_test_bufs), GFP_KERNEL);
+ } *tbufs = kzalloc_obj(struct initramfs_test_bufs);
struct initramfs_test_cpio c[] = { {
.magic = "070701",
.ino = 1,
diff --git a/io_uring/napi.c b/io_uring/napi.c
index bfc771445912..ca1c814fa73a 100644
--- a/io_uring/napi.c
+++ b/io_uring/napi.c
@@ -58,7 +58,7 @@ int __io_napi_add_id(struct io_ring_ctx *ctx, unsigned int napi_id,
}
}
- e = kmalloc(sizeof(*e), GFP_NOWAIT);
+ e = kmalloc_obj(*e, GFP_NOWAIT);
if (!e)
return -ENOMEM;
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 1b3b11405dac..86d580d4410d 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -483,8 +483,8 @@ static int io_zcrx_append_area(struct io_zcrx_ifq *ifq,
old_areas = ifq->areas;
old_nr = ifq->nr_areas;
- areas = kmalloc_array(old_nr + 1, sizeof(areas[0]),
- GFP_KERNEL_ACCOUNT | __GFP_ZERO);
+ areas = kmalloc_objs(areas[0], old_nr + 1,
+ GFP_KERNEL_ACCOUNT | __GFP_ZERO);
if (!areas)
return -ENOMEM;
if (old_areas)
diff --git a/kernel/bpf/diagnostics.c b/kernel/bpf/diagnostics.c
index b682fd2be443..0abbbe177e31 100644
--- a/kernel/bpf/diagnostics.c
+++ b/kernel/bpf/diagnostics.c
@@ -266,7 +266,7 @@ static char *diag_fmt_alloc(struct bpf_verifier_env *env, size_t size)
}
capacity = max_t(size_t, BPF_DIAG_FMT_CHUNK_SIZE, size);
- chunk = kmalloc(struct_size(chunk, data, capacity), GFP_KERNEL_ACCOUNT);
+ chunk = kmalloc_flex(*chunk, data, capacity, GFP_KERNEL_ACCOUNT);
if (!chunk)
return NULL;
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index d40cb5dd446c..c2796e8d29ea 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -511,7 +511,7 @@ static int bpf_ma_set_dtor(struct bpf_map *map, struct bpf_mem_alloc *ma,
if (IS_ERR_OR_NULL(map->record))
return 0;
- hrec = kzalloc(sizeof(*hrec), GFP_KERNEL);
+ hrec = kzalloc_obj(*hrec);
if (!hrec)
return -ENOMEM;
hrec->key_size = map->key_size;
diff --git a/kernel/bpf/liveness.c b/kernel/bpf/liveness.c
index 74fc4b3f80d6..301fc60bddc4 100644
--- a/kernel/bpf/liveness.c
+++ b/kernel/bpf/liveness.c
@@ -85,7 +85,7 @@ static struct func_instance *call_instance(struct bpf_verifier_env *env,
if (f)
return f;
- f = kvzalloc(sizeof(*f), GFP_KERNEL_ACCOUNT);
+ f = kvzalloc_obj(*f, GFP_KERNEL_ACCOUNT);
if (!f)
return ERR_PTR(-ENOMEM);
f->callsite = lookup_key;
diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c
index 589770ca3d3a..fb032dfdc0de 100644
--- a/kernel/bpf/log.c
+++ b/kernel/bpf/log.c
@@ -862,7 +862,7 @@ struct bpf_verifier_log *bpf_log_attr_create_vlog(struct bpf_log_attr *attr_log,
if (!size)
return NULL;
- log = kzalloc_obj(*log, GFP_KERNEL);
+ log = kzalloc_obj(*log);
if (!log)
return ERR_PTR(-ENOMEM);
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index e421ea2b80c3..a68e5435ca5f 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5483,7 +5483,7 @@ static int check_max_stack_depth(struct bpf_verifier_env *env)
bool priv_stack_supported;
int ret;
- dinfo = kvcalloc(env->subprog_cnt, sizeof(*dinfo), GFP_KERNEL_ACCOUNT);
+ dinfo = kvzalloc_objs(*dinfo, env->subprog_cnt, GFP_KERNEL_ACCOUNT);
if (!dinfo)
return -ENOMEM;
@@ -20536,8 +20536,7 @@ static int process_fd_array_continuous(struct bpf_verifier_env *env,
return -E2BIG;
}
- env->fd_array = kvcalloc(cnt, sizeof(*env->fd_array),
- GFP_KERNEL_ACCOUNT);
+ env->fd_array = kvzalloc_objs(*env->fd_array, cnt, GFP_KERNEL_ACCOUNT);
if (!env->fd_array)
return -ENOMEM;
env->fd_array_cnt = cnt;
diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c
index fdc070f419f6..957707158ff6 100644
--- a/kernel/dma/map_benchmark.c
+++ b/kernel/dma/map_benchmark.c
@@ -51,8 +51,7 @@ struct dma_single_map_param {
static void *dma_single_map_benchmark_prepare(struct map_benchmark_data *map)
{
- struct dma_single_map_param *params __free(kfree) = kzalloc(sizeof(*params),
- GFP_KERNEL);
+ struct dma_single_map_param *params __free(kfree) = kzalloc_obj(*params);
if (!params)
return NULL;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index a6c8e38a3110..a7adc8e34089 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -13558,9 +13558,8 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
return ERR_PTR(err);
if (has_addr_filter(event)) {
- event->addr_filter_ranges = kcalloc(pmu->nr_addr_filters,
- sizeof(struct perf_addr_filter_range),
- GFP_KERNEL);
+ event->addr_filter_ranges = kzalloc_objs(struct perf_addr_filter_range,
+ pmu->nr_addr_filters);
if (!event->addr_filter_ranges)
return ERR_PTR(-ENOMEM);
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 51ba5e1257c0..a061f54b606d 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1874,8 +1874,8 @@ static int futex_hash_allocate(unsigned int hash_slots, unsigned int flags)
free_percpu(ref);
}
- fph = kvzalloc(struct_size(fph, queues, hash_slots),
- GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
+ fph = kvzalloc_flex(*fph, queues, hash_slots,
+ GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
if (!fph)
return -ENOMEM;
@@ -2103,7 +2103,7 @@ static int __init futex_init(void)
size = sizeof(struct futex_hash_bucket) * hashsize;
order = get_order(size);
- __futex_queues = kcalloc(nr_node_ids, sizeof(*__futex_queues), GFP_KERNEL);
+ __futex_queues = kzalloc_objs(*__futex_queues, nr_node_ids);
kmemleak_not_leak(__futex_queues);
runtime_const_init(shift, __futex_shift);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 2fbff2618a1e..57eff26fa646 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -2306,7 +2306,7 @@ int request_nmi(unsigned int irq, irq_handler_t handler,
!irq_supports_nmi(desc))
return -EINVAL;
- action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
+ action = kzalloc_obj(struct irqaction);
if (!action)
return -ENOMEM;
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index e851e4b37d0e..ab6b774bcfd7 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -726,12 +726,11 @@ static int jump_label_add_module(struct module *mod)
if (static_key_sealed(key))
goto do_poke;
- jlm = kzalloc(sizeof(struct static_key_mod), GFP_KERNEL);
+ jlm = kzalloc_obj(struct static_key_mod);
if (!jlm)
return -ENOMEM;
if (!static_key_linked(key)) {
- jlm2 = kzalloc(sizeof(struct static_key_mod),
- GFP_KERNEL);
+ jlm2 = kzalloc_obj(struct static_key_mod);
if (!jlm2) {
kfree(jlm);
return -ENOMEM;
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 63beb59b7a3d..a3f95c90456b 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -852,7 +852,7 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask)
if (!zalloc_cpumask_var(&affinity, GFP_KERNEL))
return -ENOMEM;
- kthread->preferred_affinity = kzalloc(sizeof(struct cpumask), GFP_KERNEL);
+ kthread->preferred_affinity = kzalloc_obj(struct cpumask);
if (!kthread->preferred_affinity) {
ret = -ENOMEM;
goto out;
diff --git a/kernel/sched/ext/cid.c b/kernel/sched/ext/cid.c
index 39f88deb94bc..bc4eee5bb4cb 100644
--- a/kernel/sched/ext/cid.c
+++ b/kernel/sched/ext/cid.c
@@ -98,16 +98,16 @@ static struct scx_cid_tables *scx_cid_alloc_tables(void)
u32 npossible = num_possible_cpus();
struct scx_cid_tables *tbls;
- tbls = kzalloc_obj(*tbls, GFP_KERNEL);
+ tbls = kzalloc_obj(*tbls);
if (!tbls)
return NULL;
- tbls->cid_to_cpu = kvcalloc(npossible, sizeof(*tbls->cid_to_cpu), GFP_KERNEL);
- tbls->cpu_to_cid = kvcalloc(nr_cpu_ids, sizeof(*tbls->cpu_to_cid), GFP_KERNEL);
- tbls->cid_to_shard = kvcalloc(npossible, sizeof(*tbls->cid_to_shard), GFP_KERNEL);
- tbls->shard_node = kvcalloc(npossible, sizeof(*tbls->shard_node), GFP_KERNEL);
- tbls->shard_ranges = kvcalloc(npossible, sizeof(*tbls->shard_ranges), GFP_KERNEL);
- tbls->topo = kvcalloc(npossible, sizeof(*tbls->topo), GFP_KERNEL);
+ tbls->cid_to_cpu = kvzalloc_objs(*tbls->cid_to_cpu, npossible);
+ tbls->cpu_to_cid = kvzalloc_objs(*tbls->cpu_to_cid, nr_cpu_ids);
+ tbls->cid_to_shard = kvzalloc_objs(*tbls->cid_to_shard, npossible);
+ tbls->shard_node = kvzalloc_objs(*tbls->shard_node, npossible);
+ tbls->shard_ranges = kvzalloc_objs(*tbls->shard_ranges, npossible);
+ tbls->topo = kvzalloc_objs(*tbls->topo, npossible);
if (!tbls->cid_to_cpu || !tbls->cpu_to_cid || !tbls->cid_to_shard ||
!tbls->shard_node || !tbls->shard_ranges || !tbls->topo) {
@@ -490,7 +490,7 @@ __bpf_kfunc void scx_bpf_cid_override(const s32 *cpu_to_cid__arena, u32 cpu_to_c
* region that arena fault recovery covers.
*/
alloced = zalloc_cpumask_var(&seen, GFP_KERNEL);
- node_counts = kcalloc(nr_node_ids, sizeof(*node_counts), GFP_KERNEL);
+ node_counts = kzalloc_objs(*node_counts, nr_node_ids);
if (cpu_to_cid_cnt == nr_cpu_ids)
cpu_to_cid = kmemdup(cpu_to_cid__arena, cpu_to_cid_cnt * sizeof(s32),
GFP_KERNEL);
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 713aa26b2828..51de1d8b72a1 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -5449,7 +5449,7 @@ static ssize_t scx_attr_caps_show(struct kobject *kobj,
struct scx_sched *sch = container_of(kobj, struct scx_sched, kobj);
u32 npossible = num_possible_cpus();
struct scx_cmask *agg __free(kfree) =
- kzalloc(struct_size(agg, bits, SCX_CMASK_NR_WORDS(npossible)), GFP_KERNEL);
+ kzalloc_flex(*agg, bits, SCX_CMASK_NR_WORDS(npossible));
unsigned long *agg_bm __free(bitmap) = bitmap_zalloc(npossible, GFP_KERNEL);
ssize_t count = 0;
s32 cap, si;
diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
index 0554448835bd..9e7040482bde 100644
--- a/kernel/sched/ext/sub.c
+++ b/kernel/sched/ext/sub.c
@@ -194,7 +194,7 @@ s32 scx_alloc_pshards(struct scx_sched *sch)
shard_node = rcu_dereference_protected(scx_shard_node,
lockdep_is_held(&scx_enable_mutex));
- pshard = kzalloc_objs(pshard[0], scx_nr_cid_shards, GFP_KERNEL);
+ pshard = kzalloc_objs(pshard[0], scx_nr_cid_shards);
if (!pshard)
return -ENOMEM;
diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
index ddb0b12a5c4a..1e9b00997ff2 100644
--- a/kernel/trace/fprobe.c
+++ b/kernel/trace/fprobe.c
@@ -945,7 +945,7 @@ int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter
if (num < 0)
return num;
- addrs = kcalloc(num, sizeof(*addrs), GFP_KERNEL);
+ addrs = kzalloc_objs(*addrs, num);
if (!addrs)
return -ENOMEM;
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index b0963ac6fd16..9726413a6385 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2600,8 +2600,8 @@ rb_allocate_cpu_buffer(struct trace_buffer *buffer, long nr_pages, int cpu)
cpu_buffer->remote = buffer->remote;
cpu_buffer->meta_page = (struct trace_buffer_meta *)(void *)desc->meta_va;
cpu_buffer->nr_pages = nr_pages;
- cpu_buffer->subbuf_ids = kcalloc(cpu_buffer->nr_pages + 1,
- sizeof(*cpu_buffer->subbuf_ids), GFP_KERNEL);
+ cpu_buffer->subbuf_ids = kzalloc_objs(*cpu_buffer->subbuf_ids,
+ cpu_buffer->nr_pages + 1);
if (!cpu_buffer->subbuf_ids)
goto fail_free_reader;
diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
index 78fa1cbda9ac..998e6390937a 100644
--- a/kernel/trace/trace_eprobe.c
+++ b/kernel/trace/trace_eprobe.c
@@ -930,7 +930,7 @@ static int __trace_eprobe_create(int argc, const char *argv[])
} else
ep->filter_str = NULL;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx);
if (!ctx)
return -ENOMEM;
ctx->event = ep->event;
diff --git a/kernel/trace/trace_remote.c b/kernel/trace/trace_remote.c
index e6724f947170..75fa1ffc4c96 100644
--- a/kernel/trace/trace_remote.c
+++ b/kernel/trace/trace_remote.c
@@ -251,8 +251,8 @@ static int trace_remote_get(struct trace_remote *remote, int cpu)
if (cpu != RING_BUFFER_ALL_CPUS && !remote->pcpu_reader_locks) {
int lock_cpu;
- remote->pcpu_reader_locks = kcalloc(nr_cpu_ids, sizeof(*remote->pcpu_reader_locks),
- GFP_KERNEL);
+ remote->pcpu_reader_locks = kzalloc_objs(*remote->pcpu_reader_locks,
+ nr_cpu_ids);
if (!remote->pcpu_reader_locks) {
trace_remote_try_unload(remote);
return -ENOMEM;
@@ -324,7 +324,7 @@ static int __alloc_ring_buffer_iter(struct trace_remote_iterator *iter, int cpu)
return iter->rb_iter ? 0 : -ENOMEM;
}
- iter->rb_iters = kcalloc(nr_cpu_ids, sizeof(*iter->rb_iters), GFP_KERNEL);
+ iter->rb_iters = kzalloc_objs(*iter->rb_iters, nr_cpu_ids);
if (!iter->rb_iters)
return -ENOMEM;
@@ -1204,7 +1204,7 @@ remote_events_dir_header_page_read(struct file *filp, char __user *ubuf, size_t
struct trace_seq *s;
int ret;
- s = kmalloc(sizeof(*s), GFP_KERNEL);
+ s = kmalloc_obj(*s);
if (!s)
return -ENOMEM;
@@ -1227,7 +1227,7 @@ remote_events_dir_header_event_read(struct file *filp, char __user *ubuf, size_t
struct trace_seq *s;
int ret;
- s = kmalloc(sizeof(*s), GFP_KERNEL);
+ s = kmalloc_obj(*s);
if (!s)
return -ENOMEM;
diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index b767a38a74f9..2f922b63d545 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -696,7 +696,7 @@ static int __init test_rhashtable_next_key(void)
if (err)
return err;
- objs = kcalloc(n, sizeof(*objs), GFP_KERNEL);
+ objs = kzalloc_objs(*objs, n);
if (!objs) {
rhashtable_destroy(&ht);
return -ENOMEM;
diff --git a/lib/test_workqueue.c b/lib/test_workqueue.c
index 99e160bd5ad1..2bdfcbbcabb4 100644
--- a/lib/test_workqueue.c
+++ b/lib/test_workqueue.c
@@ -149,11 +149,11 @@ static int __init run_bench(int n_threads, const char *scope, const char *label)
if (ret)
return ret;
- ctxs = kcalloc(n_threads, sizeof(*ctxs), GFP_KERNEL);
+ ctxs = kzalloc_objs(*ctxs, n_threads);
if (!ctxs)
return -ENOMEM;
- tasks = kcalloc(n_threads, sizeof(*tasks), GFP_KERNEL);
+ tasks = kzalloc_objs(*tasks, n_threads);
if (!tasks) {
kfree(ctxs);
return -ENOMEM;
diff --git a/lib/tests/kunit_iov_iter.c b/lib/tests/kunit_iov_iter.c
index d9690ba1db88..32e42d8c7ca1 100644
--- a/lib/tests/kunit_iov_iter.c
+++ b/lib/tests/kunit_iov_iter.c
@@ -57,7 +57,7 @@ static void *__init iov_kunit_create_buffer(struct kunit *test,
void *buffer;
unsigned int i;
- pages = kzalloc_objs(struct page *, npages, GFP_KERNEL);
+ pages = kzalloc_objs(struct page *, npages);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pages);
*ppages = pages;
diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h
index 6a95441d193a..d61b503e319a 100644
--- a/mm/damon/tests/vaddr-kunit.h
+++ b/mm/damon/tests/vaddr-kunit.h
@@ -136,7 +136,7 @@ static void damon_do_test_apply_three_regions(struct kunit *test,
if (!t)
kunit_skip(test, "target alloc fail");
- ranges = kmalloc_array(nr_regions / 2, sizeof(*ranges), GFP_KERNEL);
+ ranges = kmalloc_objs(*ranges, nr_regions / 2);
if (!ranges) {
damon_destroy_target(t, NULL);
kunit_skip(test, "ranges alloc fail");
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index e7ad295504e4..c5bc60d16e40 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -981,7 +981,7 @@ batadv_wifi_net_device_insert(struct net_device *net_dev, u32 wifi_flags)
ASSERT_RTNL();
- device_state = kzalloc_obj(*device_state, GFP_KERNEL);
+ device_state = kzalloc_obj(*device_state);
if (!device_state)
return -ENOMEM;
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index ffd7b37e7401..3f121099eb22 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -6423,8 +6423,7 @@ static int hci_update_event_filter_sync(struct hci_dev *hdev)
goto update_scan;
}
- accept_list = kmalloc_array(num_entries, sizeof(*accept_list),
- GFP_KERNEL);
+ accept_list = kmalloc_objs(*accept_list, num_entries);
if (!accept_list) {
hci_dev_unlock(hdev);
return -ENOMEM;
diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c
index 300580c1a217..a8eda727bff1 100644
--- a/net/devlink/netlink.c
+++ b/net/devlink/netlink.c
@@ -251,7 +251,7 @@ devlink_get_parent_from_attrs_lock(struct net *net, struct nlattr **attrs)
if (!attrs[DEVLINK_ATTR_PARENT_DEV])
return ERR_PTR(-EINVAL);
- tb = kcalloc(maxtype + 1, sizeof(*tb), GFP_KERNEL);
+ tb = kzalloc_objs(*tb, maxtype + 1);
if (!tb)
return ERR_PTR(-ENOMEM);
diff --git a/net/devlink/param.c b/net/devlink/param.c
index 8ca0f3ed646c..95ac9db8c993 100644
--- a/net/devlink/param.c
+++ b/net/devlink/param.c
@@ -330,13 +330,12 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
int err;
int i;
- default_value = kcalloc(DEVLINK_PARAM_CMODE_MAX + 1,
- sizeof(*default_value), GFP_KERNEL);
+ default_value = kzalloc_objs(*default_value,
+ DEVLINK_PARAM_CMODE_MAX + 1);
if (!default_value)
return -ENOMEM;
- param_value = kcalloc(DEVLINK_PARAM_CMODE_MAX + 1,
- sizeof(*param_value), GFP_KERNEL);
+ param_value = kzalloc_objs(*param_value, DEVLINK_PARAM_CMODE_MAX + 1);
if (!param_value) {
kfree(default_value);
return -ENOMEM;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 9f053eb8b46e..04dbb2babbcd 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2931,8 +2931,8 @@ static int bpf_iter_tcp_realloc_batch(struct bpf_tcp_iter_state *iter,
{
union bpf_tcp_iter_batch_item *new_batch;
- new_batch = kvmalloc_array(new_batch_sz, sizeof(*new_batch),
- flags | __GFP_NOWARN);
+ new_batch = kvmalloc_objs(*new_batch, new_batch_sz,
+ flags | __GFP_NOWARN);
if (!new_batch)
return -ENOMEM;
diff --git a/net/mac80211/nan.c b/net/mac80211/nan.c
index 19e08661be43..c7769da9617b 100644
--- a/net/mac80211/nan.c
+++ b/net/mac80211/nan.c
@@ -659,8 +659,7 @@ int ieee80211_nan_set_peer_sched(struct ieee80211_sub_if_data *sdata,
if (!sta)
return -ENOENT;
- new_sched = kzalloc(struct_size(new_sched, channels, sched->n_channels),
- GFP_KERNEL);
+ new_sched = kzalloc_flex(*new_sched, channels, sched->n_channels);
if (!new_sched)
return -ENOMEM;
diff --git a/net/mctp/test/route-test.c b/net/mctp/test/route-test.c
index c92e3abb40d7..f05f75bf93e0 100644
--- a/net/mctp/test/route-test.c
+++ b/net/mctp/test/route-test.c
@@ -193,7 +193,7 @@ static void __mctp_route_test_init(struct kunit *test,
if (netid != MCTP_NET_ANY)
WRITE_ONCE(dev->mdev->net, netid);
- dev->mdev->addrs = kmalloc_objs(u8, 1, GFP_KERNEL);
+ dev->mdev->addrs = kmalloc_objs(u8, 1);
dev->mdev->num_addrs = 1;
dev->mdev->addrs[0] = 8;
diff --git a/net/mctp/test/utils.c b/net/mctp/test/utils.c
index 6eef8d485c25..6b131084a249 100644
--- a/net/mctp/test/utils.c
+++ b/net/mctp/test/utils.c
@@ -88,7 +88,7 @@ struct mctp_test_dev *mctp_test_create_dev_with_addr(mctp_eid_t addr)
if (!dev)
return NULL;
- dev->mdev->addrs = kmalloc_objs(u8, 1, GFP_KERNEL);
+ dev->mdev->addrs = kmalloc_objs(u8, 1);
if (!dev->mdev->addrs) {
mctp_test_destroy_dev(dev);
return NULL;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 765a92fa90d6..31fbd5a28937 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3215,7 +3215,7 @@ static int nft_trans_delhook(struct nft_hook *hook,
{
struct nft_trans_hook *trans_hook;
- trans_hook = kmalloc_obj(*trans_hook, GFP_KERNEL);
+ trans_hook = kmalloc_obj(*trans_hook);
if (!trans_hook)
return -ENOMEM;
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 66c2016f6049..f43bf768b31c 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -150,7 +150,7 @@ static int cttimeout_new_timeout(struct sk_buff *skb,
goto err_proto_put;
}
- timeout = kzalloc(sizeof(*timeout), GFP_KERNEL);
+ timeout = kzalloc_obj(*timeout);
if (timeout == NULL) {
ret = -ENOMEM;
goto err_proto_put;
diff --git a/net/rds/info.c b/net/rds/info.c
index 31e7ad108459..a57f81a05c87 100644
--- a/net/rds/info.c
+++ b/net/rds/info.c
@@ -205,7 +205,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, sockopt_t *opt)
* iterator code to allocate and hand it back.
*/
npages = iov_iter_npages(&opt->iter_out, INT_MAX);
- pages = kvmalloc_array(npages, sizeof(*pages), GFP_KERNEL);
+ pages = kvmalloc_objs(*pages, npages);
if (!pages) {
ret = -ENOMEM;
goto out;
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c
index a0aa78d89289..cbd26da44951 100644
--- a/net/rxrpc/key.c
+++ b/net/rxrpc/key.c
@@ -210,7 +210,7 @@ static int rxrpc_preparse_xdr_yfs_rxgk(struct key_preparsed_payload *prep,
if (!token)
goto nomem;
- token->rxgk = kzalloc(struct_size_t(struct rxgk_key, _key, raw_keylen), GFP_KERNEL);
+ token->rxgk = kzalloc_flex(struct rxgk_key, _key, raw_keylen);
if (!token->rxgk)
goto nomem_token;
diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c
index fdbfcaa3e2ab..5d228a402204 100644
--- a/net/sched/act_gate.c
+++ b/net/sched/act_gate.c
@@ -240,7 +240,7 @@ static int tcf_gate_copy_entries(struct tcf_gate_params *dst,
list_for_each_entry(entry, &src->entries, list) {
struct tcfg_gate_entry *new;
- new = kzalloc(sizeof(*new), GFP_ATOMIC);
+ new = kzalloc_obj(*new, GFP_ATOMIC);
if (!new) {
NL_SET_ERR_MSG(extack, "Not enough memory for entry");
return -ENOMEM;
@@ -415,7 +415,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla,
if (err < 0)
goto release_idr;
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p);
if (!p) {
err = -ENOMEM;
goto chain_put;
diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
index ff401ace4f3d..503834853306 100644
--- a/net/sched/act_tunnel_key.c
+++ b/net/sched/act_tunnel_key.c
@@ -526,7 +526,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
}
t = to_tunnel_key(*a);
- params_new = kzalloc(sizeof(*params_new), GFP_KERNEL);
+ params_new = kzalloc_obj(*params_new);
if (unlikely(!params_new)) {
NL_SET_ERR_MSG(extack, "Cannot allocate tunnel key parameters");
ret = -ENOMEM;
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index cf461ebcdde5..09a7c97e87da 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -282,9 +282,8 @@ int gss_krb5_mic_build_sg(const struct xdr_buf *body,
unsigned int overflow_nents =
nsg - XDR_BUF_TO_SG_NENTS + 1;
- *sg_overflow = kmalloc_array(overflow_nents,
- sizeof(**sg_overflow),
- GFP_NOFS);
+ *sg_overflow = kmalloc_objs(**sg_overflow, overflow_nents,
+ GFP_NOFS);
if (!*sg_overflow)
return -ENOMEM;
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index aebd97e7f66c..31a1bc60a5f6 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -625,7 +625,7 @@ int sunrpc_nl_unix_gid_get_reqs_dumpit(struct sk_buff *skb,
if (!cnt)
return 0;
- items = kcalloc(cnt, sizeof(*items), GFP_KERNEL);
+ items = kzalloc_objs(*items, cnt);
seqnos = kcalloc(cnt, sizeof(*seqnos), GFP_KERNEL);
if (!items || !seqnos) {
ret = -ENOMEM;
@@ -1326,7 +1326,7 @@ int sunrpc_nl_ip_map_get_reqs_dumpit(struct sk_buff *skb,
if (!cnt)
return 0;
- items = kcalloc(cnt, sizeof(*items), GFP_KERNEL);
+ items = kzalloc_objs(*items, cnt);
seqnos = kcalloc(cnt, sizeof(*seqnos), GFP_KERNEL);
if (!items || !seqnos) {
ret = -ENOMEM;
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index cb2ef428651f..c42fd338c607 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -371,8 +371,7 @@ int xdr_buf_to_sg_alloc(const struct xdr_buf *buf, unsigned int offset,
unsigned int overflow_nents = nsg - sg_head_nents + 1;
struct scatterlist *overflow;
- overflow = kmalloc_array(overflow_nents, sizeof(*overflow),
- gfp);
+ overflow = kmalloc_objs(*overflow, overflow_nents, gfp);
if (!overflow)
return -ENOMEM;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 13f9926bf205..79c3921c583c 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -3667,8 +3667,8 @@ static int bpf_iter_unix_realloc_batch(struct bpf_unix_iter_state *iter,
{
struct sock **new_batch;
- new_batch = kvmalloc_array(new_batch_sz, sizeof(*new_batch),
- GFP_USER | __GFP_NOWARN);
+ new_batch = kvmalloc_objs(*new_batch, new_batch_sz,
+ GFP_USER | __GFP_NOWARN);
if (!new_batch)
return -ENOMEM;
diff --git a/net/wireless/core.c b/net/wireless/core.c
index d13310fef691..3032993ba5dc 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -311,9 +311,8 @@ int cfg80211_nan_set_local_schedule(struct cfg80211_registered_device *rdev,
if (!sched->n_channels)
return 0;
- wdev->u.nan.chandefs = kcalloc(sched->n_channels,
- sizeof(*wdev->u.nan.chandefs),
- GFP_KERNEL);
+ wdev->u.nan.chandefs = kzalloc_objs(*wdev->u.nan.chandefs,
+ sched->n_channels);
if (!wdev->u.nan.chandefs)
return -ENOMEM;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 44f2bad08670..899b6374c550 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -17330,8 +17330,7 @@ static int nl80211_parse_nan_channel(struct cfg80211_registered_device *rdev,
u8 n_rx_nss;
int ret;
- channel_parsed = kcalloc(NL80211_ATTR_MAX + 1, sizeof(*channel_parsed),
- GFP_KERNEL);
+ channel_parsed = kzalloc_objs(*channel_parsed, NL80211_ATTR_MAX + 1);
if (!channel_parsed)
return -ENOMEM;
@@ -17554,8 +17553,7 @@ static int nl80211_nan_set_peer_sched(struct sk_buff *skb,
}
if (n_channels) {
- nan_channels = kcalloc(n_channels, sizeof(*nan_channels),
- GFP_KERNEL);
+ nan_channels = kzalloc_objs(*nan_channels, n_channels);
if (!nan_channels)
return -ENOMEM;
}
@@ -17693,8 +17691,7 @@ static int nl80211_nan_set_local_sched(struct sk_buff *skb,
info->nlhdr, GENL_HDRLEN, rem)
n_channels++;
- sched = kzalloc(struct_size(sched, nan_channels, n_channels),
- GFP_KERNEL);
+ sched = kzalloc_flex(*sched, nan_channels, n_channels);
if (!sched)
return -ENOMEM;
diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
index f89f0ca3d4ed..0f1b7e4113c4 100644
--- a/security/integrity/ima/ima_queue.c
+++ b/security/integrity/ima/ima_queue.c
@@ -75,8 +75,7 @@ static struct hlist_head *ima_alloc_replace_htable(void)
struct hlist_head *old_htable, *new_htable;
/* Initializing to zeros is equivalent to call HLIST_HEAD_INIT. */
- new_htable = kcalloc(IMA_MEASURE_HTABLE_SIZE, sizeof(struct hlist_head),
- GFP_KERNEL);
+ new_htable = kzalloc_objs(struct hlist_head, IMA_MEASURE_HTABLE_SIZE);
if (!new_htable)
return ERR_PTR(-ENOMEM);
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 23d62fede06e..7c397b1c9231 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -107,7 +107,7 @@ static int snd_compr_open(struct inode *inode, struct file *f)
return -EINVAL;
}
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data);
if (!data) {
snd_card_unref(compr->card);
return -ENOMEM;
@@ -119,7 +119,7 @@ static int snd_compr_open(struct inode *inode, struct file *f)
data->stream.direction = dirn;
data->stream.private_data = compr->private_data;
data->stream.device = compr;
- runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
+ runtime = kzalloc_obj(*runtime);
if (!runtime) {
kfree(data);
snd_card_unref(compr->card);
diff --git a/sound/core/control.c b/sound/core/control.c
index 78ce7bc936d2..4199342d4ffe 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -69,7 +69,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
err = -ENODEV;
goto __error2;
}
- ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
+ ctl = kzalloc_obj(*ctl);
if (ctl == NULL) {
err = -ENOMEM;
goto __error;
@@ -174,7 +174,7 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
goto _found;
}
}
- ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
+ ev = kzalloc_obj(*ev, GFP_ATOMIC);
if (ev) {
ev->id = *id;
ev->mask = mask;
@@ -871,7 +871,7 @@ static int snd_ctl_card_info(struct snd_card *card, struct snd_ctl_file * ctl,
unsigned int cmd, void __user *arg)
{
struct snd_ctl_card_info *info __free(kfree) =
- kzalloc(sizeof(*info), GFP_KERNEL);
+ kzalloc_obj(*info);
ssize_t n;
if (! info)
diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 3d13bbec1c54..ec0e6c7ad657 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -158,7 +158,7 @@ static void snd_ctl_led_set_state(struct snd_card *card, unsigned int access,
UPDATE_ROUTE(route, snd_ctl_led_get(lctl));
}
if (!found && kctl && card) {
- lctl = kzalloc(sizeof(*lctl), GFP_KERNEL);
+ lctl = kzalloc_obj(*lctl);
if (lctl) {
lctl->card = card;
lctl->access = access;
diff --git a/sound/core/init.c b/sound/core/init.c
index 2f7f83a7611b..9693e646b3bb 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -364,7 +364,7 @@ static int snd_card_init(struct snd_card *card, struct device *parent,
sound_debugfs_root);
#endif
#ifdef CONFIG_SND_CTL_DEBUG
- card->value_buf = kmalloc(sizeof(*card->value_buf), GFP_KERNEL);
+ card->value_buf = kmalloc_obj(*card->value_buf);
if (!card->value_buf)
return -ENOMEM;
#endif
diff --git a/sound/core/misc.c b/sound/core/misc.c
index 4772b2a3b808..066fb9ecdcdc 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -125,7 +125,7 @@ int snd_fasync_helper(int fd, struct file *file, int on,
struct snd_fasync *fasync = NULL;
if (on) {
- fasync = kzalloc(sizeof(*fasync), GFP_KERNEL);
+ fasync = kzalloc_obj(*fasync);
if (!fasync)
return -ENOMEM;
INIT_LIST_HEAD(&fasync->list);
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index ff9d7fd60a7e..c533d767c29a 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -890,7 +890,7 @@ static int snd_mixer_oss_build_test(struct snd_mixer_oss *mixer, struct slot *sl
int err;
struct snd_ctl_elem_info *info __free(kfree) =
- kmalloc(sizeof(*info), GFP_KERNEL);
+ kmalloc_obj(*info);
if (!info)
return -ENOMEM;
scoped_guard(rwsem_read, &card->controls_rwsem) {
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 62324282fcae..6d32c12fb79b 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2330,7 +2330,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
return -EINVAL;
struct snd_pcm_group *group __free(kfree) =
- kzalloc(sizeof(*group), GFP_KERNEL);
+ kzalloc_obj(*group);
if (!group)
return -ENOMEM;
snd_pcm_group_init(group);
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
index c4b82e29ab05..21a0a98c8e92 100644
--- a/sound/core/seq/oss/seq_oss_synth.c
+++ b/sound/core/seq/oss/seq_oss_synth.c
@@ -86,7 +86,7 @@ snd_seq_oss_synth_probe(struct snd_seq_device *dev)
struct seq_oss_synth *rec;
struct snd_seq_oss_reg *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
- rec = kzalloc(sizeof(*rec), GFP_KERNEL);
+ rec = kzalloc_obj(*rec);
if (!rec)
return -ENOMEM;
rec->seq_device = -1;
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 5b86e75c2658..239809ce48d7 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -210,7 +210,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
struct snd_seq_client *client;
/* init client data */
- client = kzalloc(sizeof(*client), GFP_KERNEL);
+ client = kzalloc_obj(*client);
if (client == NULL)
return NULL;
client->pool = snd_seq_pool_new(poolsize);
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
index 6208bf7f57bf..a01785a6de9b 100644
--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -188,7 +188,7 @@ static int snd_virmidi_input_open(struct snd_rawmidi_substream *substream)
struct snd_rawmidi_runtime *runtime = substream->runtime;
struct snd_virmidi *vmidi;
- vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL);
+ vmidi = kzalloc_obj(*vmidi);
if (vmidi == NULL)
return -ENOMEM;
vmidi->substream = substream;
diff --git a/sound/core/timer.c b/sound/core/timer.c
index f666f05e9d45..679b26435670 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1855,7 +1855,7 @@ static int snd_timer_user_info(struct file *file,
return -EBADFD;
struct snd_timer_info *info __free(kfree) =
- kzalloc(sizeof(*info), GFP_KERNEL);
+ kzalloc_obj(*info);
if (! info)
return -ENOMEM;
info->card = t->card ? t->card->number : -1;
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 4e3ea23ca913..81cb1f59f703 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -1365,7 +1365,7 @@ static int loopback_open(struct snd_pcm_substream *substream)
int dev = get_cable_index(substream);
guard(mutex)(&loopback->cable_lock);
- dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
+ dpcm = kzalloc_obj(*dpcm);
if (!dpcm)
return -ENOMEM;
dpcm->loopback = loopback;
@@ -1373,7 +1373,7 @@ static int loopback_open(struct snd_pcm_substream *substream)
cable = loopback->cables[substream->number][dev];
if (!cable) {
- cable = kzalloc(sizeof(*cable), GFP_KERNEL);
+ cable = kzalloc_obj(*cable);
if (!cable) {
err = -ENOMEM;
goto unlock;
diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c
index 30bd76eee96e..7be6ff201ecb 100644
--- a/sound/isa/gus/gus_dma.c
+++ b/sound/isa/gus/gus_dma.c
@@ -214,7 +214,7 @@ int snd_gf1_dma_transfer_block(struct snd_gus_card * gus,
struct snd_gf1_dma_block *block;
struct snd_gf1_dma_block *free_block = NULL;
- block = kmalloc(sizeof(*block), atomic ? GFP_ATOMIC : GFP_KERNEL);
+ block = kmalloc_obj(*block, atomic ? GFP_ATOMIC : GFP_KERNEL);
if (!block)
return -ENOMEM;
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 19a6927c079d..f6db08b75649 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -1444,7 +1444,7 @@ static int _cs46xx_playback_open_channel (struct snd_pcm_substream *substream,in
struct snd_cs46xx_pcm * cpcm;
struct snd_pcm_runtime *runtime = substream->runtime;
- cpcm = kzalloc(sizeof(*cpcm), GFP_KERNEL);
+ cpcm = kzalloc_obj(*cpcm);
if (cpcm == NULL)
return -ENOMEM;
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
diff --git a/sound/pci/ctxfi/ctamixer.c b/sound/pci/ctxfi/ctamixer.c
index 5fc1c922620a..f356917cb6ac 100644
--- a/sound/pci/ctxfi/ctamixer.c
+++ b/sound/pci/ctxfi/ctamixer.c
@@ -236,7 +236,7 @@ static int get_amixer_rsc(struct amixer_mgr *mgr,
*ramixer = NULL;
/* Allocate mem for amixer resource */
- amixer = kzalloc(sizeof(*amixer), GFP_KERNEL);
+ amixer = kzalloc_obj(*amixer);
if (!amixer)
return -ENOMEM;
@@ -390,7 +390,7 @@ static int get_sum_rsc(struct sum_mgr *mgr,
*rsum = NULL;
/* Allocate mem for sum resource */
- sum = kzalloc(sizeof(*sum), GFP_KERNEL);
+ sum = kzalloc_obj(*sum);
if (!sum)
return -ENOMEM;
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index 69aacd06716c..9be70c6862ab 100644
--- a/sound/pci/ctxfi/ctdaio.c
+++ b/sound/pci/ctxfi/ctdaio.c
@@ -540,7 +540,7 @@ static int get_daio_rsc(struct daio_mgr *mgr,
err = -ENOMEM;
/* Allocate mem for daio resource */
if (desc->output) {
- struct dao *dao = kzalloc(sizeof(*dao), GFP_KERNEL);
+ struct dao *dao = kzalloc_obj(*dao);
if (!dao)
goto error;
@@ -552,7 +552,7 @@ static int get_daio_rsc(struct daio_mgr *mgr,
*rdaio = &dao->daio;
} else {
- struct dai *dai = kzalloc(sizeof(*dai), GFP_KERNEL);
+ struct dai *dai = kzalloc_obj(*dai);
if (!dai)
goto error;
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
index 46dc1f509234..1fadaf22309f 100644
--- a/sound/pci/ctxfi/ctsrc.c
+++ b/sound/pci/ctxfi/ctsrc.c
@@ -432,9 +432,9 @@ get_src_rsc(struct src_mgr *mgr, const struct src_desc *desc, struct src **rsrc)
/* Allocate mem for master src resource */
if (MEMRD == desc->mode)
- src = kcalloc(desc->multi, sizeof(*src), GFP_KERNEL);
+ src = kzalloc_objs(*src, desc->multi);
else
- src = kzalloc(sizeof(*src), GFP_KERNEL);
+ src = kzalloc_obj(*src);
if (!src) {
err = -ENOMEM;
diff --git a/sound/pci/ctxfi/cttimer.c b/sound/pci/ctxfi/cttimer.c
index cc379d880cad..9d6f5df2bc7e 100644
--- a/sound/pci/ctxfi/cttimer.c
+++ b/sound/pci/ctxfi/cttimer.c
@@ -318,7 +318,7 @@ ct_timer_instance_new(struct ct_timer *atimer, struct ct_atc_pcm *apcm)
{
struct ct_timer_instance *ti;
- ti = kzalloc(sizeof(*ti), GFP_KERNEL);
+ ti = kzalloc_obj(*ti);
if (!ti)
return NULL;
spin_lock_init(&ti->lock);
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 49cabb2eb2b7..a33817aba17f 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -2470,7 +2470,7 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
emu->support_tlv = 1;
return put_user(SNDRV_EMU10K1_VERSION, (int __user *)argp);
case SNDRV_EMU10K1_IOCTL_INFO:
- info = kzalloc(sizeof(*info), GFP_KERNEL);
+ info = kzalloc_obj(*info, GFP_KERNEL);
if (!info)
return -ENOMEM;
snd_emu10k1_fx8010_info(emu, info);
diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-amplifier.c
index ca53b08c0b33..07c040355c37 100644
--- a/sound/soc/codecs/simple-amplifier.c
+++ b/sound/soc/codecs/simple-amplifier.c
@@ -371,7 +371,7 @@ static unsigned int *simple_amp_alloc_tlv_ranges(const struct simple_amp_ranges
unsigned int *t;
unsigned int i;
- tlv = kzalloc_objs(*tlv, 2 + ranges->nb_ranges * 6, GFP_KERNEL);
+ tlv = kzalloc_objs(*tlv, 2 + ranges->nb_ranges * 6);
if (!tlv)
return NULL;
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 42019daa5e04..5f3423129b13 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -168,7 +168,7 @@ int simple_util_parse_tdm_width_map(struct simple_util_priv *priv, struct device
if (!dai->tdm_width_map)
return simple_ret(priv, ret); /* see NOTE */
- u32 *array_values __free(kfree) = kcalloc(n, sizeof(*array_values), GFP_KERNEL);
+ u32 *array_values __free(kfree) = kzalloc_objs(*array_values, n);
if (!array_values)
goto end;
diff --git a/sound/soc/meson/gx-formatter.c b/sound/soc/meson/gx-formatter.c
index 311e63affb23..2d3218cce426 100644
--- a/sound/soc/meson/gx-formatter.c
+++ b/sound/soc/meson/gx-formatter.c
@@ -253,7 +253,7 @@ struct gx_stream *gx_stream_alloc(struct gx_iface *iface)
{
struct gx_stream *ts;
- ts = kzalloc(sizeof(*ts), GFP_KERNEL);
+ ts = kzalloc_obj(*ts);
if (ts) {
INIT_LIST_HEAD(&ts->formatter_list);
mutex_init(&ts->lock);
diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index 1d68a80e8e0c..f0ff1350e9dd 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -1857,7 +1857,7 @@ struct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id)
return ERR_PTR(-EINVAL);
}
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return ERR_PTR(-ENOMEM);
diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c
index e01d91eb3cc8..32d9b7f30a4f 100644
--- a/sound/soc/sdca/sdca_functions.c
+++ b/sound/soc/sdca/sdca_functions.c
@@ -1249,8 +1249,7 @@ static int find_sdca_entity_pde(struct device *dev,
return -EINVAL;
}
- u32 *delay_list __free(kfree) = kcalloc(num_delays, sizeof(*delay_list),
- GFP_KERNEL);
+ u32 *delay_list __free(kfree) = kzalloc_objs(*delay_list, num_delays);
if (!delay_list)
return -ENOMEM;
@@ -1313,8 +1312,8 @@ static int find_sdca_entity_ge(struct device *dev,
return -EINVAL;
}
- u8 *affected_list __free(kfree) = kcalloc(num_affected, sizeof(*affected_list),
- GFP_KERNEL);
+ u8 *affected_list __free(kfree) = kzalloc_objs(*affected_list,
+ num_affected);
if (!affected_list)
return -ENOMEM;
@@ -1552,8 +1551,8 @@ static int find_sdca_entities(struct device *dev, struct fwnode_handle *function
if (!entities)
return -ENOMEM;
- u32 *entity_list __free(kfree) = kcalloc(num_entities, sizeof(*entity_list),
- GFP_KERNEL);
+ u32 *entity_list __free(kfree) = kzalloc_objs(*entity_list,
+ num_entities);
if (!entity_list)
return -ENOMEM;
@@ -1715,8 +1714,8 @@ static int find_sdca_entity_connection_pde(struct device *dev,
if (!managed)
return -ENOMEM;
- u32 *managed_list __free(kfree) = kcalloc(num_managed, sizeof(*managed_list),
- GFP_KERNEL);
+ u32 *managed_list __free(kfree) = kzalloc_objs(*managed_list,
+ num_managed);
if (!managed_list)
return -ENOMEM;
@@ -2033,8 +2032,8 @@ static int find_sdca_clusters(struct device *dev,
if (!clusters)
return -ENOMEM;
- u32 *cluster_list __free(kfree) = kcalloc(num_clusters, sizeof(*cluster_list),
- GFP_KERNEL);
+ u32 *cluster_list __free(kfree) = kzalloc_objs(*cluster_list,
+ num_clusters);
if (!cluster_list)
return -ENOMEM;
diff --git a/sound/soc/sof/sof-client-probes-ipc4.c b/sound/soc/sof/sof-client-probes-ipc4.c
index 2eef32b55395..c547ea61fb3d 100644
--- a/sound/soc/sof/sof-client-probes-ipc4.c
+++ b/sound/soc/sof/sof-client-probes-ipc4.c
@@ -260,7 +260,7 @@ static int ipc4_probes_points_info(struct sof_client_dev *cdev,
*num_desc = info->num_elems;
dev_dbg(dev, "%s: got %zu probe points", __func__, *num_desc);
- *desc = kcalloc(*num_desc, sizeof(**desc), GFP_KERNEL);
+ *desc = kzalloc_objs(**desc, *num_desc);
if (!*desc) {
kfree(msg.data_ptr);
return -ENOMEM;
diff --git a/sound/soc/sof/sof-client.c b/sound/soc/sof/sof-client.c
index c7bbf09e547f..64da8df15bf2 100644
--- a/sound/soc/sof/sof-client.c
+++ b/sound/soc/sof/sof-client.c
@@ -230,7 +230,7 @@ int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id,
struct sof_client_dev *cdev;
int ret;
- centry = kzalloc(sizeof(*centry), GFP_KERNEL);
+ centry = kzalloc_obj(*centry);
if (!centry)
return -ENOMEM;
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c
index da04ed5cbac4..d746b2586d88 100644
--- a/sound/sparc/amd7930.c
+++ b/sound/sparc/amd7930.c
@@ -903,7 +903,7 @@ static int snd_amd7930_create(struct snd_card *card,
int err;
*ramd = NULL;
- amd = kzalloc(sizeof(*amd), GFP_KERNEL);
+ amd = kzalloc_obj(*amd);
if (amd == NULL)
return -ENOMEM;