struct crypto_aes_ctx *rk;
int err;
- rk = kmalloc(sizeof(*rk), GFP_KERNEL);
+ rk = kmalloc_obj(*rk);
if (!rk)
return -ENOMEM;
struct crypto_aes_ctx *rk;
int err;
- rk = kmalloc(sizeof(*rk), GFP_KERNEL);
+ rk = kmalloc_obj(*rk);
if (!rk)
return -ENOMEM;
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;
return -EINVAL;
}
- s = kzalloc(sizeof(struct loongarch_dmsintc), GFP_KERNEL);
+ s = kzalloc_obj(struct loongarch_dmsintc);
if (!s)
return -ENOMEM;
/* 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;
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;
}
}
- 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;
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;
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;
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 *));
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;
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;
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;
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;
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
*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);
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;
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;
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;
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;
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;
/* 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);
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;
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;
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;
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;
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;
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);
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;
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;
{
struct dma_fence *f;
- f = kmalloc(sizeof(*f), GFP_KERNEL);
+ f = kmalloc_obj(*f);
if (!f)
return NULL;
long ret = -EINVAL;
u32 i, flags;
- ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL);
+ ubuf = kzalloc_obj(*ubuf);
if (!ubuf)
return -ENOMEM;
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;
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;
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;
/*
* Create the switchtec dma device
*/
- swdma_dev = kzalloc_obj(*swdma_dev, GFP_KERNEL);
+ swdma_dev = kzalloc_obj(*swdma_dev);
if (!swdma_dev)
return -ENOMEM;
layers[1].is_virt_csrow = false;
rc = -ENOMEM;
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = kzalloc_obj(*dev);
if (!dev)
return rc;
{
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);
{
int ret;
- u64 *handle __free(kfree) = kzalloc(sizeof(*handle), GFP_KERNEL);
+ u64 *handle __free(kfree) = kzalloc_obj(*handle);
if (!handle)
return -ENOMEM;
{
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;
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;
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,
if (user_addr + length < user_addr)
return -EINVAL;
- region = kzalloc(sizeof(*region), GFP_KERNEL);
+ region = kzalloc_obj(*region);
if (!region)
return -ENOMEM;
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);
* 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;
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);
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);
struct gpio_chardev_data *cdev;
int ret = -ENOMEM;
- cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
+ cdev = kzalloc_obj(*cdev);
if (!cdev)
return -ENOMEM;
int base = 0;
int ret;
- gdev = kzalloc(sizeof(*gdev), GFP_KERNEL);
+ gdev = kzalloc_obj(*gdev);
if (!gdev)
return -ENOMEM;
gc->gpiodev = gdev;
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;
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;
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;
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;
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;
struct amdgpu_lockdep_dummy_locks *locks;
unsigned long flags;
- locks = kzalloc(sizeof(*locks), GFP_KERNEL);
+ locks = kzalloc_obj(*locks);
if (!locks)
return -ENOMEM;
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;
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;
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
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;
} 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);
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);
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;
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;
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;
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;
{
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,
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);
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;
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;
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;
*/
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;
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;
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;
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;
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;
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);
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;
* 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;
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);
* 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. */
}
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();
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)
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;
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;
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;
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) {
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) {
*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;
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;
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;
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) {
}
/* 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);
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 */
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);
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 */
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);
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 */
}
/* 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);
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 */
}
/* 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);
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 */
}
/* 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);
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 */
}
/* 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);
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 */
}
/* 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);
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 */
}
/* 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);
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 */
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);
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 */
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);
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 */
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);
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 */
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);
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 */
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;
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;
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;
{
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;
uint32_t inst)
{
struct dcn20_hubp *hubp2 =
- kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_hubp);
if (!hubp2)
return NULL;
uint32_t inst)
{
struct dcn42_dpp *dpp42 =
- kzalloc(sizeof(struct dcn42_dpp), GFP_KERNEL);
+ kzalloc_obj(struct dcn42_dpp);
if (!dpp42)
return NULL;
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;
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();
uint32_t instance)
{
struct optc *tgn10 =
- kzalloc(sizeof(struct optc), GFP_KERNEL);
+ kzalloc_obj(struct optc);
if (!tgn10)
return NULL;
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;
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;
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;
} 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);
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);
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 */
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);
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 */
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
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");
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");
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();
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;
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;
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;
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;
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;
{
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;
uint32_t inst)
{
struct dcn20_hubp *hubp2 =
- kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_hubp);
if (!hubp2)
return NULL;
uint32_t inst)
{
struct dcn42_dpp *dpp42b =
- kzalloc(sizeof(struct dcn42_dpp), GFP_KERNEL);
+ kzalloc_obj(struct dcn42_dpp);
if (!dpp42b)
return NULL;
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;
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();
uint32_t instance)
{
struct optc *tgn10 =
- kzalloc(sizeof(struct optc), GFP_KERNEL);
+ kzalloc_obj(struct optc);
if (!tgn10)
return NULL;
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;
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;
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;
} 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);
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);
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 */
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
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");
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");
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();
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;
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;
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;
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;
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;
{
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;
uint32_t inst)
{
struct dcn20_hubp *hubp2 =
- kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
+ kzalloc_obj(struct dcn20_hubp);
if (!hubp2)
return NULL;
uint32_t inst)
{
struct dcn60_dpp *dpp60 =
- kzalloc(sizeof(struct dcn60_dpp), GFP_KERNEL);
+ kzalloc_obj(struct dcn60_dpp);
if (!dpp60)
return NULL;
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;
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();
uint32_t instance)
{
struct optc *tgn10 =
- kzalloc(sizeof(struct optc), GFP_KERNEL);
+ kzalloc_obj(struct optc);
if (!tgn10)
return NULL;
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);
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;
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;
} 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);
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);
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 */
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);
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 */
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
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();
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;
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;
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;
}
* (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;
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;
smu_table->metrics_time = 0;
- driver_pptable = kzalloc(sizeof(PPTable_t), GFP_KERNEL);
+ driver_pptable = kzalloc_obj(PPTable_t);
if (!driver_pptable)
return -ENOMEM;
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;
}
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;
(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;
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;
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;
return ERR_PTR(-EINVAL);
}
- plane = kzalloc(sizeof(*plane), GFP_KERNEL);
+ plane = kzalloc_obj(*plane);
if (!plane)
return ERR_PTR(-ENOMEM);
{
struct property *prop;
- prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+ prop = kzalloc_obj(*prop);
if (!prop)
return -ENOMEM;
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;
plane->state = NULL;
}
- vs_state = kzalloc_obj(*vs_state, GFP_KERNEL);
+ vs_state = kzalloc_obj(*vs_state);
if (!vs_state)
return;
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;
if (dev->enabled)
return ERR_PTR(-EBUSY);
- crtc = kzalloc(sizeof(*crtc), GFP_KERNEL);
+ crtc = kzalloc_obj(*crtc);
if (!crtc)
return ERR_PTR(-ENOMEM);
if (dev->enabled)
return ERR_PTR(-EBUSY);
- plane = kzalloc(sizeof(*plane), GFP_KERNEL);
+ plane = kzalloc_obj(*plane);
if (!plane)
return ERR_PTR(-ENOMEM);
if (dev->enabled)
return ERR_PTR(-EBUSY);
- encoder = kzalloc(sizeof(*encoder), GFP_KERNEL);
+ encoder = kzalloc_obj(*encoder);
if (!encoder)
return ERR_PTR(-ENOMEM);
if (dev->enabled)
return ERR_PTR(-EBUSY);
- connector = kzalloc(sizeof(*connector), GFP_KERNEL);
+ connector = kzalloc_obj(*connector);
if (!connector)
return ERR_PTR(-ENOMEM);
{
struct xe_amc *amc;
- amc = kzalloc(sizeof(*amc), GFP_KERNEL);
+ amc = kzalloc_obj(*amc);
if (!amc)
return -ENOMEM;
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;
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;
return -EINVAL;
}
- action = kzalloc(sizeof(struct asus_work_action), GFP_NOWAIT);
+ action = kzalloc_obj(struct asus_work_action, GFP_NOWAIT);
if (!action)
return -ENOMEM;
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;
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;
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;
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;
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;
*/
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;
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;
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;
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;
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;
return list;
}
- list = kzalloc(sizeof(*list), GFP_KERNEL);
+ list = kzalloc_obj(*list);
if (!list)
return NULL;
}
}
- scl = kzalloc(sizeof(*scl), GFP_KERNEL);
+ scl = kzalloc_obj(*scl);
if (!scl) {
if (sharable)
fwnode_handle_put(args.fwnode);
{
struct xi3c_xfer *xfer;
- xfer = kzalloc_flex(*xfer, cmds, ncmds, GFP_KERNEL);
+ xfer = kzalloc_flex(*xfer, cmds, ncmds);
if (!xfer)
return NULL;
if (!xfer)
return -ENOMEM;
- buf = kmalloc_objs(*buf, xfer_len, GFP_KERNEL);
+ buf = kmalloc_objs(*buf, xfer_len);
if (!buf)
return -ENOMEM;
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;
if (nents < 0)
return nents;
- vecs = kmalloc_array(nents, sizeof(*vecs), GFP_ATOMIC);
+ vecs = kmalloc_objs(*vecs, nents, GFP_ATOMIC);
if (!vecs)
return -ENOMEM;
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;
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;
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;
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;
"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;
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;
{
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)
struct psmouse_smbus_dev *smbdev;
int error;
- smbdev = kzalloc(sizeof(*smbdev), GFP_KERNEL);
+ smbdev = kzalloc_obj(*smbdev);
if (!smbdev)
return -ENOMEM;
if (serio_raw->dead)
return -ENODEV;
- client = kzalloc(sizeof(*client), GFP_KERNEL);
+ client = kzalloc_obj(*client);
if (!client)
return -ENOMEM;
{
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;
{
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);
if (!length || !PAGE_ALIGNED(length))
return -EINVAL;
- immap = kzalloc(sizeof(*immap), GFP_KERNEL);
+ immap = kzalloc_obj(*immap);
if (!immap)
return -ENOMEM;
immap->owner = owner;
(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);
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;
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;
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;
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;
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);
return -EINVAL;
}
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx);
if (!ctx) {
ti->error = "Out of memory";
return -ENOMEM;
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;
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;
unsigned int cpb_size_max;
unsigned int cpb_size_def;
- channel = kzalloc(sizeof(*channel), GFP_KERNEL);
+ channel = kzalloc_obj(*channel);
if (!channel)
return -ENOMEM;
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;
/* 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;
{
struct isp4if_img_buf_node *node;
- node = kmalloc_obj(*node, GFP_KERNEL);
+ node = kmalloc_obj(*node);
if (node)
node->buf_info = *buf_info;
}
/* Memory is released when the job is consumed. */
- job = kzalloc(sizeof(*job), GFP_KERNEL);
+ job = kzalloc_obj(*job);
if (!job)
return -ENOMEM;
if (!ir)
return -ENOMEM;
- ir->request = kzalloc_obj(*ir->request, GFP_KERNEL);
+ ir->request = kzalloc_obj(*ir->request);
if (!ir->request)
goto fail;
return -EAGAIN;
allocate_of_node:
- of_entry = kzalloc(sizeof(*of_entry), GFP_KERNEL);
+ of_entry = kzalloc_obj(*of_entry);
if (!of_entry)
return -ENOMEM;
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;
struct ucb1x00_assabet_priv *priv;
- priv = kzalloc_obj(*priv, GFP_KERNEL);
+ priv = kzalloc_obj(*priv);
if (!priv)
return -ENOMEM;
return 0;
}
- item = kzalloc_flex(*item, nodes, count, GFP_KERNEL);
+ item = kzalloc_flex(*item, nodes, count);
if (!item)
return -ENOMEM;
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;
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",
goto err_unlock;
}
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry) {
err = -ENOMEM;
goto err_unlock;
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;
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;
num = enet->edev->rx_num;
- irq_blks = kvcalloc(num, sizeof(*blk), GFP_KERNEL);
+ irq_blks = kvzalloc_objs(*blk, num);
if (!irq_blks)
return -ENOMEM;
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;
int err;
u32 mtu;
- cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ cfg = kzalloc_obj(*cfg);
if (!cfg)
return -ENOMEM;
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;
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;
struct eea_net_rx *rx;
int err;
- rx = kzalloc(sizeof(*rx), GFP_KERNEL);
+ rx = kzalloc_obj(*rx);
if (!rx)
return rx;
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;
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;
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;
if (!length)
return 0;
- deferred = kmalloc_obj(*deferred, GFP_KERNEL);
+ deferred = kmalloc_obj(*deferred);
if (!deferred)
return -ENOMEM;
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;
u8 *component_data;
int err;
- deferred = kmalloc_obj(*deferred, GFP_KERNEL);
+ deferred = kmalloc_obj(*deferred);
if (!deferred)
return -ENOMEM;
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;
{
struct enic_admin_msg *msg;
- msg = kmalloc(struct_size(msg, data, len), GFP_KERNEL);
+ msg = kmalloc_flex(*msg, data, len);
if (!msg)
return;
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;
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;
return 0;
}
- pp = kzalloc_obj(*enic->pp, GFP_KERNEL);
+ pp = kzalloc_obj(*enic->pp);
if (!pp)
return -ENOMEM;
goto out;
}
- a = kzalloc(sizeof(*a), GFP_KERNEL);
+ a = kzalloc_obj(*a);
if (!a) {
err = -ENOMEM;
goto out;
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;
*/
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;
{
struct npc_defrag_show_node *node;
- node = kcalloc(1, sizeof(*node), GFP_KERNEL);
+ node = kzalloc_objs(*node, 1);
if (!node)
return -ENOMEM;
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;
return -EINVAL;
}
- npc_priv = kcalloc(1, sizeof(*npc_priv), GFP_KERNEL);
+ npc_priv = kzalloc_objs(*npc_priv, 1);
if (!npc_priv)
return -ENOMEM;
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;
/* 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;
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;
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;
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;
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;
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)
/* 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;
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);
*msi_requested = msi;
}
- gic = kzalloc(sizeof(*gic), GFP_KERNEL);
+ gic = kzalloc_obj(*gic);
if (!gic) {
gic = ERR_PTR(-ENOMEM);
if (irq_map.virq)
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;
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;
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;
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;
mlink = &msta->deflink;
is_deflink = true;
} else {
- mlink = kzalloc(sizeof(*mlink), GFP_KERNEL);
+ mlink = kzalloc_obj(*mlink);
if (!mlink) {
err = -ENOMEM;
break;
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;
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;
}
}
- 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;
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 {
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;
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;
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;
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;
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;
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));
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;
if (!tb[NXPWIFI_TM_ATTR_DATA])
return -EINVAL;
- hostcmd = kzalloc_obj(*hostcmd, GFP_KERNEL);
+ hostcmd = kzalloc_obj(*hostcmd);
if (!hostcmd)
return -ENOMEM;
/* 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;
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;
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;
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;
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;
}
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;
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;
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;
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;
int ret = 0;
int i;
- adapter = kzalloc_obj(*adapter, GFP_KERNEL);
+ adapter = kzalloc_obj(*adapter);
if (!adapter)
return ERR_PTR(-ENOMEM);
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;
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)
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);
}
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;
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;
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;
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;
return 0;
}
- bgscan_cfg = kzalloc_obj(*bgscan_cfg, GFP_KERNEL);
+ bgscan_cfg = kzalloc_obj(*bgscan_cfg);
if (!bgscan_cfg)
return -ENOMEM;
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;
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);
struct nxpwifi_sta_node *node;
int len, i;
- sinfo = kzalloc_obj(*sinfo, GFP_KERNEL);
+ sinfo = kzalloc_obj(*sinfo);
if (!sinfo)
return -ENOMEM;
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;
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",
count++;
}
- qlist = kcalloc(count, sizeof(*qlist), GFP_KERNEL);
+ qlist = kzalloc_objs(*qlist, count);
if (!qlist) {
err = -ENOMEM;
goto out_free_val;
count = opp_table->regulator_count;
- uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL);
+ uV = kmalloc_objs(*uV, count);
if (!uV)
return 0;
{
struct opp_device *opp_dev;
- opp_dev = kzalloc(sizeof(*opp_dev), GFP_KERNEL);
+ opp_dev = kzalloc_obj(*opp_dev);
if (!opp_dev)
return NULL;
return -ENODEV;
struct pci_epc_aux_resource *res __free(kfree) =
- kcalloc(count, sizeof(*res), GFP_KERNEL);
+ kzalloc_objs(*res, count);
if (!res)
return -ENOMEM;
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;
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;
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;
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);
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;
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;
continue;
}
- info = kzalloc_obj(*info, GFP_KERNEL);
+ info = kzalloc_obj(*info);
if (!info) {
ret = -ENOMEM;
goto error;
!config->targets[0])
return ERR_PTR(-EINVAL);
- pwrseq = kzalloc(sizeof(*pwrseq), GFP_KERNEL);
+ pwrseq = kzalloc_obj(*pwrseq);
if (!pwrseq)
return ERR_PTR(-ENOMEM);
}
}
- pci_dev = kzalloc(sizeof(*pci_dev), GFP_KERNEL);
+ pci_dev = kzalloc_obj(*pci_dev);
if (!pci_dev) {
ret = -ENOMEM;
goto err_put_ctrl;
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;
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;
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);
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);
{
struct dasd_device *device;
- device = kzalloc_obj(struct dasd_device, GFP_KERNEL);
+ device = kzalloc_obj(struct dasd_device);
if (!device)
return ERR_PTR(-ENOMEM);
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;
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);
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;
}
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",
return;
}
- raid_volume = kzalloc(sizeof(*raid_volume), GFP_KERNEL);
+ raid_volume = kzalloc_obj(*raid_volume);
if (!raid_volume)
return;
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;
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;
}
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 =
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;
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->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;
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;
* 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);
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;
if (!info->fwnode || !info->ops || !info->ops->match)
return -EINVAL;
- trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
+ trigger = kzalloc_obj(*trigger);
if (!trigger)
return -ENOMEM;
if (minor < 0)
return minor;
- raw = kzalloc_obj(*raw, GFP_KERNEL);
+ raw = kzalloc_obj(*raw);
if (!raw) {
ida_free(&minors, minor);
return -ENOMEM;
}
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;
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;
/* 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 {
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;
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;
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;
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);
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);
{
struct tbstream *stream;
- stream = kzalloc_obj(*stream, GFP_KERNEL);
+ stream = kzalloc_obj(*stream);
if (!stream)
return -ENOMEM;
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;
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;
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;
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 };
int status;
/* allocate and initialize one new instance */
- ncm = kzalloc(sizeof(*ncm), GFP_KERNEL);
+ ncm = kzalloc_obj(*ncm);
if (!ncm)
return ERR_PTR(-ENOMEM);
size = np * sizeof(*iso);
- buff = kcalloc(np, sizeof(*iso), GFP_KERNEL);
+ buff = kzalloc_objs(*iso, np);
if (!buff)
return -ENOMEM;
/* 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;
*/
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;
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);
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;
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;
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);
}
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;
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;
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;
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;
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);
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;
* 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;
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;
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;
return -EPERM;
}
- ks = kmalloc(sizeof(*ks), GFP_KERNEL_ACCOUNT);
+ ks = kmalloc_obj(*ks, GFP_KERNEL_ACCOUNT);
if (!ks)
return -ENOMEM;
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;
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) {
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;
{
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;
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;
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;
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;
end_cluster = vol->nr_clusters;
}
- ra = kzalloc(sizeof(*ra), GFP_NOFS);
+ ra = kzalloc_obj(*ra, GFP_NOFS);
if (!ra)
return -ENOMEM;
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);
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;
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);
*/
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;
*/
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;
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;
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);
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;
}
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;
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;
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;
memset(empty_buf, 0xff, vol->cluster_size);
- ra = kzalloc(sizeof(*ra), GFP_NOFS);
+ ra = kzalloc_obj(*ra, GFP_NOFS);
if (!ra)
goto err;
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;
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);
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;
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;
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;
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;
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;
{
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);
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;
} 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;
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);
* 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;
}
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,
}
}
- e = kmalloc(sizeof(*e), GFP_NOWAIT);
+ e = kmalloc_obj(*e, GFP_NOWAIT);
if (!e)
return -ENOMEM;
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)
}
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;
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;
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;
if (!size)
return NULL;
- log = kzalloc_obj(*log, GFP_KERNEL);
+ log = kzalloc_obj(*log);
if (!log)
return ERR_PTR(-ENOMEM);
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;
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;
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;
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);
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;
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);
!irq_supports_nmi(desc))
return -EINVAL;
- action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
+ action = kzalloc_obj(struct irqaction);
if (!action)
return -ENOMEM;
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;
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;
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) {
* 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);
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;
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;
if (num < 0)
return num;
- addrs = kcalloc(num, sizeof(*addrs), GFP_KERNEL);
+ addrs = kzalloc_objs(*addrs, num);
if (!addrs)
return -ENOMEM;
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;
} else
ep->filter_str = NULL;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx);
if (!ctx)
return -ENOMEM;
ctx->event = ep->event;
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;
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;
struct trace_seq *s;
int ret;
- s = kmalloc(sizeof(*s), GFP_KERNEL);
+ s = kmalloc_obj(*s);
if (!s)
return -ENOMEM;
struct trace_seq *s;
int ret;
- s = kmalloc(sizeof(*s), GFP_KERNEL);
+ s = kmalloc_obj(*s);
if (!s)
return -ENOMEM;
if (err)
return err;
- objs = kcalloc(n, sizeof(*objs), GFP_KERNEL);
+ objs = kzalloc_objs(*objs, n);
if (!objs) {
rhashtable_destroy(&ht);
return -ENOMEM;
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;
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;
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");
ASSERT_RTNL();
- device_state = kzalloc_obj(*device_state, GFP_KERNEL);
+ device_state = kzalloc_obj(*device_state);
if (!device_state)
return -ENOMEM;
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;
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);
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;
{
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;
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;
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;
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;
{
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;
goto err_proto_put;
}
- timeout = kzalloc(sizeof(*timeout), GFP_KERNEL);
+ timeout = kzalloc_obj(*timeout);
if (timeout == NULL) {
ret = -ENOMEM;
goto err_proto_put;
* 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;
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;
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;
if (err < 0)
goto release_idr;
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p);
if (!p) {
err = -ENOMEM;
goto chain_put;
}
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;
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;
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;
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;
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;
{
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;
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;
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;
}
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;
}
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;
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);
return -EINVAL;
}
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data);
if (!data) {
snd_card_unref(compr->card);
return -ENOMEM;
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);
err = -ENODEV;
goto __error2;
}
- ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
+ ctl = kzalloc_obj(*ctl);
if (ctl == NULL) {
err = -ENOMEM;
goto __error;
goto _found;
}
}
- ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
+ ev = kzalloc_obj(*ev, GFP_ATOMIC);
if (ev) {
ev->id = *id;
ev->mask = mask;
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)
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;
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
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);
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) {
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);
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;
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);
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;
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;
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;
cable = loopback->cables[substream->number][dev];
if (!cable) {
- cable = kzalloc(sizeof(*cable), GFP_KERNEL);
+ cable = kzalloc_obj(*cable);
if (!cable) {
err = -ENOMEM;
goto unlock;
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;
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,
*ramixer = NULL;
/* Allocate mem for amixer resource */
- amixer = kzalloc(sizeof(*amixer), GFP_KERNEL);
+ amixer = kzalloc_obj(*amixer);
if (!amixer)
return -ENOMEM;
*rsum = NULL;
/* Allocate mem for sum resource */
- sum = kzalloc(sizeof(*sum), GFP_KERNEL);
+ sum = kzalloc_obj(*sum);
if (!sum)
return -ENOMEM;
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;
*rdaio = &dao->daio;
} else {
- struct dai *dai = kzalloc(sizeof(*dai), GFP_KERNEL);
+ struct dai *dai = kzalloc_obj(*dai);
if (!dai)
goto error;
/* 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;
{
struct ct_timer_instance *ti;
- ti = kzalloc(sizeof(*ti), GFP_KERNEL);
+ ti = kzalloc_obj(*ti);
if (!ti)
return NULL;
spin_lock_init(&ti->lock);
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);
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;
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;
{
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);
return ERR_PTR(-EINVAL);
}
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return ERR_PTR(-ENOMEM);
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;
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;
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;
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;
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;
*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;
struct sof_client_dev *cdev;
int ret;
- centry = kzalloc(sizeof(*centry), GFP_KERNEL);
+ centry = kzalloc_obj(*centry);
if (!centry)
return -ENOMEM;
int err;
*ramd = NULL;
- amd = kzalloc(sizeof(*amd), GFP_KERNEL);
+ amd = kzalloc_obj(*amd);
if (amd == NULL)
return -ENOMEM;