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>
This commit is contained in:
Kees Cook 2026-09-02 15:31:14 -07:00 committed by Kees Cook
parent 90feea391c
commit 3a2c4d55e3
304 changed files with 637 additions and 726 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 *));

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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. */

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More