treewide: refresh kmalloc_obj() conversions

Refresh the tree with run of the existing Coccinelle rules in
scripts/coccinelle/api/kmalloc_objs.cocci, now that they also convert
arrays of multi-byte integers.

The conversions break down as:

	435	kzalloc_objs()
	169	kmalloc_objs()
	 52	kvzalloc_objs()
	 47	kzalloc_obj()
	 42	kvmalloc_objs()
	  8	kmalloc_obj()
	  2	kzalloc_flex()
	  2	kvmalloc_flex()

and 37 existing kmalloc_obj() family calls drop a redundant GFP_KERNEL.

Build tested with allmodconfig on x86_64 with GCC 16.2.0, and, together
with the devm_kmalloc_obj() conversion that follows, on x86_64, arm64,
i386, arm, riscv, s390, m68k, mips, parisc, sparc, loongarch, arc,
xtensa, and openrisc with GCC 16.2.0 with no new warnings.

Signed-off-by: Kees Cook <[email protected]>
This commit is contained in:
Kees Cook
2026-11-05 21:55:37 -08:00
committed by Kees Cook
parent d68ce4e712
commit 0af298e62e
519 changed files with 931 additions and 1213 deletions
+1 -2
View File
@@ -1101,8 +1101,7 @@ static void fill_ill_insn(void *area, unsigned int size)
/* Piece of memory that can be allocated at the beginning of jit_prepare(). */
static int jit_prepare_early_mem_alloc(struct jit_context *ctx)
{
ctx->bpf2insn = kcalloc(ctx->prog->len, sizeof(ctx->jit.len),
GFP_KERNEL);
ctx->bpf2insn = kzalloc_objs(ctx->jit.len, ctx->prog->len);
if (!ctx->bpf2insn) {
pr_err("bpf-jit: could not allocate memory for "
+1 -2
View File
@@ -92,8 +92,7 @@ static void __init parse_dt_topology(void)
unsigned long capacity = 0;
int cpu = 0;
__cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity),
GFP_NOWAIT);
__cpu_capacity = kzalloc_objs(*__cpu_capacity, nr_cpu_ids, GFP_NOWAIT);
for_each_possible_cpu(cpu) {
const __be32 *rate;
+1 -3
View File
@@ -102,9 +102,7 @@ static int __init pxa_pm_init(void)
return -EINVAL;
}
sleep_save = kmalloc_array(pxa_cpu_pm_fns->save_count,
sizeof(*sleep_save),
GFP_KERNEL);
sleep_save = kmalloc_objs(*sleep_save, pxa_cpu_pm_fns->save_count);
if (!sleep_save)
return -ENOMEM;
+1 -1
View File
@@ -2199,7 +2199,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
ctx.idx += ctx.imm_count;
if (ctx.imm_count) {
ctx.imms = kcalloc(ctx.imm_count, sizeof(u32), GFP_KERNEL);
ctx.imms = kzalloc_objs(u32, ctx.imm_count);
if (ctx.imms == NULL)
goto out_off;
}
+1 -2
View File
@@ -170,8 +170,7 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
static int __init cpu_suspend_init(void)
{
/* ctx_ptr is an array of physical addresses */
sleep_save_stash = kcalloc(mpidr_hash_size(), sizeof(*sleep_save_stash),
GFP_KERNEL);
sleep_save_stash = kzalloc_objs(*sleep_save_stash, mpidr_hash_size());
if (WARN_ON(!sleep_save_stash))
return -ENOMEM;
+1 -1
View File
@@ -506,7 +506,7 @@ static int set_ccsidr(struct kvm_vcpu *vcpu, u32 csselr, u32 val)
if (val == get_ccsidr(vcpu, csselr))
return 0;
ccsidr = kmalloc_array(CSSELR_MAX, sizeof(u32), GFP_KERNEL_ACCOUNT);
ccsidr = kmalloc_objs(u32, CSSELR_MAX, GFP_KERNEL_ACCOUNT);
if (!ccsidr)
return -ENOMEM;
+2 -2
View File
@@ -1000,8 +1000,8 @@ int kvm_vgic_v5_irs_init(struct kvm *kvm, unsigned int nr_spis)
* provide at least 32 SPIs, so we always meet alignment requirements.
*/
if (nr_spis) {
dist->spis = kcalloc(nr_spis, sizeof(struct vgic_irq),
GFP_KERNEL_ACCOUNT);
dist->spis = kzalloc_objs(struct vgic_irq, nr_spis,
GFP_KERNEL_ACCOUNT);
if (!dist->spis)
return -ENOMEM;
+3 -4
View File
@@ -198,8 +198,7 @@ static int vgic_v5_alloc_vmt_two_level(unsigned int num_entries)
return -ENOMEM;
vmt_info->l2.l2ptrs = kzalloc_objs(*vmt_info->l2.l2ptrs,
vmt_info->l2.num_l1_ents,
GFP_KERNEL);
vmt_info->l2.num_l1_ents);
if (!vmt_info->l2.l2ptrs) {
kfree(vmt_info->l2.vmt_base);
return -ENOMEM;
@@ -296,7 +295,7 @@ int vgic_v5_vmt_allocate(unsigned int max_vpes)
int ret;
/* Allocate the tracking structure */
vmt_info = kzalloc_obj(*vmt_info, GFP_KERNEL);
vmt_info = kzalloc_obj(*vmt_info);
if (!vmt_info)
return -ENOMEM;
@@ -1598,7 +1597,7 @@ static int vgic_v5_track_pending_irq(struct list_head *pending_irqs, u32 intid,
{
struct vgic_v5_pending_irq *pirq;
pirq = kzalloc_obj(*pirq, GFP_KERNEL);
pirq = kzalloc_obj(*pirq);
if (!pirq)
return -ENOMEM;
+1 -1
View File
@@ -2301,7 +2301,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
ctx.user_vm_start = bpf_arena_get_user_vm_start(prog->aux->arena);
}
ctx.offset = kvcalloc(prog->len + 1, sizeof(u32), GFP_KERNEL);
ctx.offset = kvzalloc_objs(u32, prog->len + 1);
if (ctx.offset == NULL)
goto out_offset;
+1 -1
View File
@@ -361,7 +361,7 @@ static void *cps_gen_entry_code(unsigned cpu, enum cps_pm_state state)
};
/* Allocate a buffer to hold the generated code */
p = buf = kcalloc(max_instrs, sizeof(u32), GFP_KERNEL);
p = buf = kzalloc_objs(u32, max_instrs);
if (!buf)
return NULL;
+1 -2
View File
@@ -959,8 +959,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
* Not able to allocate memory for descriptors[], then
* we must fall back to the interpreter
*/
ctx.descriptors = kcalloc(prog->len + 1, sizeof(*ctx.descriptors),
GFP_KERNEL);
ctx.descriptors = kzalloc_objs(*ctx.descriptors, prog->len + 1);
if (ctx.descriptors == NULL)
goto out_err;
+1 -1
View File
@@ -824,7 +824,7 @@ static int parse_thread_groups(struct device_node *dn,
int i = 0;
count = of_property_count_u32_elems(dn, "ibm,thread-groups");
thread_group_array = kcalloc(count, sizeof(u32), GFP_KERNEL);
thread_group_array = kzalloc_objs(u32, count);
if (!thread_group_array)
return -ENOMEM;
ret = of_property_read_u32_array(dn, "ibm,thread-groups",
+3 -6
View File
@@ -804,9 +804,7 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
goto free_privs_first;
}
g2h_bitmap = kcalloc(params.tlb_sizes[1],
sizeof(*g2h_bitmap),
GFP_KERNEL);
g2h_bitmap = kzalloc_objs(*g2h_bitmap, params.tlb_sizes[1]);
if (!g2h_bitmap) {
ret = -ENOMEM;
goto free_privs_second;
@@ -930,9 +928,8 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
if (!vcpu_e500->gtlb_priv[1])
goto free_vcpu;
vcpu_e500->g2h_tlb1_map = kcalloc(vcpu_e500->gtlb_params[1].entries,
sizeof(*vcpu_e500->g2h_tlb1_map),
GFP_KERNEL);
vcpu_e500->g2h_tlb1_map = kzalloc_objs(*vcpu_e500->g2h_tlb1_map,
vcpu_e500->gtlb_params[1].entries);
if (!vcpu_e500->g2h_tlb1_map)
goto free_vcpu;
+2 -3
View File
@@ -741,9 +741,8 @@ int e500_mmu_host_init(struct kvmppc_vcpu_e500 *vcpu_e500)
host_tlb_params[0].sets =
host_tlb_params[0].entries / host_tlb_params[0].ways;
host_tlb_params[1].sets = 1;
vcpu_e500->h2g_tlb1_rmap = kcalloc(host_tlb_params[1].entries,
sizeof(*vcpu_e500->h2g_tlb1_rmap),
GFP_KERNEL);
vcpu_e500->h2g_tlb1_rmap = kzalloc_objs(*vcpu_e500->h2g_tlb1_rmap,
host_tlb_params[1].entries);
if (!vcpu_e500->h2g_tlb1_rmap)
return -EINVAL;
+2 -2
View File
@@ -258,7 +258,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
goto skip_init_ctx;
}
addrs = kcalloc(flen + 1, sizeof(*addrs), GFP_KERNEL);
addrs = kzalloc_objs(*addrs, flen + 1);
if (addrs == NULL)
goto out_err;
@@ -1104,7 +1104,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im
}
if (fmod_ret->nr_nodes) {
branches = kcalloc(fmod_ret->nr_nodes, sizeof(u32), GFP_KERNEL);
branches = kzalloc_objs(u32, fmod_ret->nr_nodes);
if (!branches)
return -ENOMEM;
+2 -2
View File
@@ -1338,8 +1338,8 @@ static int __init pnv_parse_cpuidle_dt(void)
"ibm,cpu-idle-state-flags");
pnv_idle_states = kzalloc_objs(*pnv_idle_states, nr_idle_states);
temp_u32 = kcalloc(nr_idle_states, sizeof(u32), GFP_KERNEL);
temp_u64 = kcalloc(nr_idle_states, sizeof(u64), GFP_KERNEL);
temp_u32 = kzalloc_objs(u32, nr_idle_states);
temp_u64 = kzalloc_objs(u64, nr_idle_states);
temp_string = kcalloc(nr_idle_states, sizeof(char *), GFP_KERNEL);
if (!(pnv_idle_states && temp_u32 && temp_u64 && temp_string)) {
+2 -2
View File
@@ -91,11 +91,11 @@ static int imc_get_mem_addr_nest(struct device_node *node,
if (nr_chips <= 0)
return -ENODEV;
base_addr_arr = kcalloc(nr_chips, sizeof(*base_addr_arr), GFP_KERNEL);
base_addr_arr = kzalloc_objs(*base_addr_arr, nr_chips);
if (!base_addr_arr)
return -ENOMEM;
chipid_arr = kcalloc(nr_chips, sizeof(*chipid_arr), GFP_KERNEL);
chipid_arr = kzalloc_objs(*chipid_arr, nr_chips);
if (!chipid_arr) {
kfree(base_addr_arr);
return -ENOMEM;
@@ -185,14 +185,14 @@ void __init opal_sys_param_init(void)
goto out_param_buf;
}
id = kcalloc(count, sizeof(*id), GFP_KERNEL);
id = kzalloc_objs(*id, count);
if (!id) {
pr_err("SYSPARAM: Failed to allocate memory to read parameter "
"id\n");
goto out_param_buf;
}
size = kcalloc(count, sizeof(*size), GFP_KERNEL);
size = kzalloc_objs(*size, count);
if (!size) {
pr_err("SYSPARAM: Failed to allocate memory to read parameter "
"size\n");
+1 -1
View File
@@ -254,7 +254,7 @@ void *uv_alloc_stor_var(unsigned long size)
area = get_vm_area(size, VM_SPARSE);
if (!area)
return NULL;
pages = kvcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL_ACCOUNT);
pages = kvzalloc_objs(struct page *, nr_pages, GFP_KERNEL_ACCOUNT);
if (!pages)
goto free_area;
for (i = 0; i < nr_pages; i++) {
+1 -1
View File
@@ -2397,7 +2397,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
}
memset(&jit, 0, sizeof(jit));
jit.addrs = kvcalloc(fp->len + 1, sizeof(*jit.addrs), GFP_KERNEL);
jit.addrs = kvzalloc_objs(*jit.addrs, fp->len + 1);
if (jit.addrs == NULL)
goto out_err;
/*
+2 -2
View File
@@ -1079,8 +1079,8 @@ static int zpci_mem_init(void)
if (!zpci_iomap_start)
goto error_iomap;
zpci_iomap_bitmap = kcalloc(BITS_TO_LONGS(ZPCI_IOMAP_ENTRIES),
sizeof(*zpci_iomap_bitmap), GFP_KERNEL);
zpci_iomap_bitmap = kzalloc_objs(*zpci_iomap_bitmap,
BITS_TO_LONGS(ZPCI_IOMAP_ENTRIES));
if (!zpci_iomap_bitmap)
goto error_iomap_bitmap;
+1 -2
View File
@@ -172,8 +172,7 @@ static int __init check_nmi_watchdog(void)
if (!atomic_read(&nmi_active))
return 0;
prev_nmi_count = kmalloc_array(nr_cpu_ids, sizeof(unsigned int),
GFP_KERNEL);
prev_nmi_count = kmalloc_objs(unsigned int, nr_cpu_ids);
if (!prev_nmi_count) {
err = -ENOMEM;
goto error;
+1 -1
View File
@@ -335,7 +335,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
if (!bpf_jit_enable)
return;
addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL);
addrs = kmalloc_objs(*addrs, flen);
if (addrs == NULL)
return;
+1 -1
View File
@@ -1511,7 +1511,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
memset(&ctx, 0, sizeof(ctx));
ctx.prog = prog;
ctx.offset = kmalloc_array(prog->len, sizeof(unsigned int), GFP_KERNEL);
ctx.offset = kmalloc_objs(unsigned int, prog->len);
if (ctx.offset == NULL)
goto out_err;
+1 -2
View File
@@ -394,8 +394,7 @@ static bool uncore_discovery_msr(struct uncore_discovery_domain *domain)
int cpu, die;
u64 base;
die_mask = kcalloc(BITS_TO_LONGS(uncore_max_dies()),
sizeof(unsigned long), GFP_KERNEL);
die_mask = kzalloc_objs(unsigned long, BITS_TO_LONGS(uncore_max_dies()));
if (!die_mask)
return false;
+1 -1
View File
@@ -228,7 +228,7 @@ static void amd_cache_gart(void)
if (!amd_nb_has_feature(AMD_NB_GART))
return;
flush_words = kmalloc_array(amd_northbridges.num, sizeof(u32), GFP_KERNEL);
flush_words = kmalloc_objs(u32, amd_northbridges.num);
if (!flush_words) {
amd_northbridges.flags &= ~AMD_NB_GART;
pr_notice("Cannot initialize GART flush words, GART support disabled\n");
+1 -1
View File
@@ -209,7 +209,7 @@ static int x2apic_cluster_probe(void)
return 0;
slots = max_t(u32, L1_CACHE_BYTES/sizeof(u32), nr_cpu_ids);
x86_cpu_to_logical_apicid = kcalloc(slots, sizeof(u32), GFP_KERNEL);
x86_cpu_to_logical_apicid = kzalloc_objs(u32, slots);
if (!x86_cpu_to_logical_apicid)
return 0;
+1 -1
View File
@@ -43,7 +43,7 @@ mtrr_file_add(unsigned long base, unsigned long size,
max = num_var_ranges;
if (fcount == NULL) {
fcount = kcalloc(max, sizeof(*fcount), GFP_KERNEL);
fcount = kzalloc_objs(*fcount, max);
if (!fcount)
return -ENOMEM;
FILE_FCOUNT(file) = fcount;
+1 -2
View File
@@ -408,8 +408,7 @@ static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_ctrl_domain *
struct msr_param m;
u32 *dc;
dc = kmalloc_array(hw_res->num_closid, sizeof(*hw_dom->ctrl_val),
GFP_KERNEL);
dc = kmalloc_objs(*hw_dom->ctrl_val, hw_res->num_closid);
if (!dc)
return -ENOMEM;
+1 -1
View File
@@ -103,7 +103,7 @@ static int kvm_mmu_rmaps_stat_show(struct seq_file *m, void *v)
ret = -ENOMEM;
memset(log, 0, sizeof(log));
for (i = 0; i < KVM_NR_PAGE_SIZES; i++) {
log[i] = kcalloc(RMAP_LOG_SIZE, sizeof(unsigned int), GFP_KERNEL);
log[i] = kzalloc_objs(unsigned int, RMAP_LOG_SIZE);
if (!log[i])
goto out;
}
+3 -2
View File
@@ -3024,8 +3024,9 @@ static int tdx_td_vcpu_init(struct kvm_vcpu *vcpu, u64 vcpu_rcx)
*/
tdx->vp.tdvpr_pa = page_to_phys(tdx->vp.tdvpr_page);
tdx->vp.tdcx_pages = kcalloc(kvm_tdx->td.tdcx_nr_pages, sizeof(*tdx->vp.tdcx_pages),
GFP_KERNEL_ACCOUNT);
tdx->vp.tdcx_pages = kzalloc_objs(*tdx->vp.tdcx_pages,
kvm_tdx->td.tdcx_nr_pages,
GFP_KERNEL_ACCOUNT);
if (!tdx->vp.tdcx_pages) {
ret = -ENOMEM;
goto free_tdvpr;
+1 -1
View File
@@ -272,7 +272,7 @@ static int pefile_digest_pe_contents(const void *pebuf, unsigned int pelen,
if (ret < 0)
return ret;
canon = kcalloc(ctx->n_sections, sizeof(unsigned), GFP_KERNEL);
canon = kzalloc_objs(unsigned, ctx->n_sections);
if (!canon)
return -ENOMEM;
+1 -1
View File
@@ -566,7 +566,7 @@ static int aie2_hwctx_col_list(struct amdxdna_hwctx *hwctx)
return -EINVAL;
}
hwctx->col_list = kmalloc_array(entries, sizeof(*hwctx->col_list), GFP_KERNEL);
hwctx->col_list = kmalloc_objs(*hwctx->col_list, entries);
if (!hwctx->col_list)
return -ENOMEM;
+1 -1
View File
@@ -712,7 +712,7 @@ static int amdxdna_drm_submit_execbuf(struct amdxdna_client *client,
cmd_bo_hdl = (u32)args->cmd_handles;
if (args->arg_count) {
arg_bo_hdls = kcalloc(args->arg_count, sizeof(u32), GFP_KERNEL);
arg_bo_hdls = kzalloc_objs(u32, args->arg_count);
if (!arg_bo_hdls)
return -ENOMEM;
ret = copy_from_user(arg_bo_hdls, u64_to_user_ptr(args->args),
@@ -947,11 +947,12 @@ static int allocate_cs(struct hl_device *hdev, struct hl_ctx *ctx,
goto free_cs;
}
cs->jobs_in_queue_cnt = kcalloc(hdev->asic_prop.max_queues,
sizeof(*cs->jobs_in_queue_cnt), GFP_ATOMIC);
cs->jobs_in_queue_cnt = kzalloc_objs(*cs->jobs_in_queue_cnt,
hdev->asic_prop.max_queues,
GFP_ATOMIC);
if (!cs->jobs_in_queue_cnt)
cs->jobs_in_queue_cnt = kcalloc(hdev->asic_prop.max_queues,
sizeof(*cs->jobs_in_queue_cnt), GFP_KERNEL);
cs->jobs_in_queue_cnt = kzalloc_objs(*cs->jobs_in_queue_cnt,
hdev->asic_prop.max_queues);
if (!cs->jobs_in_queue_cnt) {
atomic64_inc(&ctx->cs_counters.out_of_mem_drop_cnt);
@@ -1899,13 +1900,11 @@ static int cs_ioctl_extract_signal_seq(struct hl_device *hdev,
return -EINVAL;
}
signal_seq_arr = kmalloc_array(signal_seq_arr_len,
sizeof(*signal_seq_arr),
GFP_ATOMIC);
signal_seq_arr = kmalloc_objs(*signal_seq_arr, signal_seq_arr_len,
GFP_ATOMIC);
if (!signal_seq_arr)
signal_seq_arr = kmalloc_array(signal_seq_arr_len,
sizeof(*signal_seq_arr),
GFP_KERNEL);
signal_seq_arr = kmalloc_objs(*signal_seq_arr,
signal_seq_arr_len);
if (!signal_seq_arr) {
atomic64_inc(&ctx->cs_counters.out_of_mem_drop_cnt);
atomic64_inc(&hdev->aggregated_cs_counters.out_of_mem_drop_cnt);
@@ -2479,7 +2478,7 @@ static int cs_ioctl_engine_cores(struct hl_fpriv *hpriv, u64 engine_cores,
}
engine_cores_arr = (void __user *) (uintptr_t) engine_cores;
cores = kmalloc_array(num_engine_cores, sizeof(u32), GFP_KERNEL);
cores = kmalloc_objs(u32, num_engine_cores);
if (!cores)
return -ENOMEM;
@@ -2521,7 +2520,7 @@ static int cs_ioctl_engines(struct hl_fpriv *hpriv, u64 engines_arr_user_addr,
}
engines_arr = (void __user *) (uintptr_t) engines_arr_user_addr;
engines = kmalloc_array(num_engines, sizeof(u32), GFP_KERNEL);
engines = kmalloc_objs(u32, num_engines);
if (!engines)
return -ENOMEM;
@@ -3037,7 +3036,7 @@ static int hl_multi_cs_wait_ioctl(struct hl_fpriv *hpriv, void *data)
/* allocate memory for sequence array */
cs_seq_arr =
kmalloc_array(seq_arr_len, sizeof(*cs_seq_arr), GFP_KERNEL);
kmalloc_objs(*cs_seq_arr, seq_arr_len);
if (!cs_seq_arr)
return -ENOMEM;
+1 -1
View File
@@ -178,7 +178,7 @@ int hl_build_hwmon_channel_info(struct hl_device *hdev, struct cpucp_sensor *sen
num_sensors_for_type = counts[i] + 1;
dev_dbg(hdev->dev, "num_sensors_for_type %d = %d\n", i, num_sensors_for_type);
curr_arr = kcalloc(num_sensors_for_type, sizeof(*curr_arr), GFP_KERNEL);
curr_arr = kzalloc_objs(*curr_arr, num_sensors_for_type);
if (!curr_arr) {
rc = -ENOMEM;
goto sensors_type_err;
+2 -3
View File
@@ -139,7 +139,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
phys_pg_pack->flags = args->flags;
phys_pg_pack->contiguous = contiguous;
phys_pg_pack->pages = kvmalloc_array(num_pgs, sizeof(u64), GFP_KERNEL);
phys_pg_pack->pages = kvmalloc_objs(u64, num_pgs);
if (ZERO_OR_NULL_PTR(phys_pg_pack->pages)) {
rc = -ENOMEM;
goto pages_arr_err;
@@ -885,8 +885,7 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx,
page_mask = ~(((u64) page_size) - 1);
phys_pg_pack->pages = kvmalloc_array(total_npages, sizeof(u64),
GFP_KERNEL);
phys_pg_pack->pages = kvmalloc_objs(u64, total_npages);
if (ZERO_OR_NULL_PTR(phys_pg_pack->pages)) {
rc = -ENOMEM;
goto page_pack_arr_mem_err;
+3 -5
View File
@@ -8989,14 +8989,12 @@ static int gaudi_print_fences_single_engine(
int rc = -ENOMEM, i;
u32 *statuses, *fences;
statuses = kcalloc(sds->props[SP_ENGINE_NUM_OF_QUEUES],
sizeof(*statuses), GFP_KERNEL);
statuses = kzalloc_objs(*statuses, sds->props[SP_ENGINE_NUM_OF_QUEUES]);
if (!statuses)
goto out;
fences = kcalloc(sds->props[SP_ENGINE_NUM_OF_FENCES] *
sds->props[SP_ENGINE_NUM_OF_QUEUES],
sizeof(*fences), GFP_KERNEL);
fences = kzalloc_objs(*fences,
sds->props[SP_ENGINE_NUM_OF_FENCES] * sds->props[SP_ENGINE_NUM_OF_QUEUES]);
if (!fences)
goto free_status;
@@ -2717,7 +2717,7 @@ static int gaudi2_init_pb_sm_objs(struct hl_device *hdev)
array_base = gaudi2_pb_dcr0_sm_objs.mm_block_base_addr +
gaudi2_pb_dcr0_sm_objs.glbl_sec_offset;
sec_array = kcalloc(glbl_sec_array_len, sizeof(u32), GFP_KERNEL);
sec_array = kzalloc_objs(u32, glbl_sec_array_len);
if (!sec_array)
return -ENOMEM;
+1 -1
View File
@@ -914,7 +914,7 @@ static int ivpu_submit(struct drm_file *file, struct ivpu_file_priv *file_priv,
u32 *buf_handles;
int idx, ret;
buf_handles = kcalloc(buffer_count, sizeof(u32), GFP_KERNEL);
buf_handles = kzalloc_objs(u32, buffer_count);
if (!buf_handles)
return -ENOMEM;
+1 -2
View File
@@ -543,8 +543,7 @@ retry:
pr_warn(FW_WARN "too many record IDs!\n");
return 0;
}
new_entries = kvmalloc_array(new_size, sizeof(entries[0]),
GFP_KERNEL);
new_entries = kvmalloc_objs(entries[0], new_size);
if (!new_entries)
return -ENOMEM;
memcpy(new_entries, entries,
+3 -6
View File
@@ -913,9 +913,8 @@ static int cpc_register_non_mmio_desc(struct cpc_desc *cpc_desc)
if (!found)
return 0;
cpc_desc->non_mmio_nodes = kcalloc(nr_regs,
sizeof(*cpc_desc->non_mmio_nodes),
GFP_KERNEL);
cpc_desc->non_mmio_nodes = kzalloc_objs(*cpc_desc->non_mmio_nodes,
nr_regs);
if (!cpc_desc->non_mmio_nodes)
return -ENOMEM;
@@ -1254,9 +1253,7 @@ static int cpc_register_sysmem_desc(struct cpc_desc *cpc_desc)
if (!found)
return 0;
cpc_desc->sysmem_nodes = kcalloc(nr_regs,
sizeof(*cpc_desc->sysmem_nodes),
GFP_KERNEL);
cpc_desc->sysmem_nodes = kzalloc_objs(*cpc_desc->sysmem_nodes, nr_regs);
if (!cpc_desc->sysmem_nodes)
return -ENOMEM;
+3 -5
View File
@@ -280,9 +280,8 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
&cpu_capacity);
if (!ret) {
if (!raw_capacity) {
raw_capacity = kcalloc(num_possible_cpus(),
sizeof(*raw_capacity),
GFP_KERNEL);
raw_capacity = kzalloc_objs(*raw_capacity,
num_possible_cpus());
if (!raw_capacity) {
cap_parsing_failed = true;
return false;
@@ -333,8 +332,7 @@ static inline void topology_init_cpu_capacity_cppc(void)
if (likely(!acpi_cpc_valid()))
return;
raw_capacity = kcalloc(num_possible_cpus(), sizeof(*raw_capacity),
GFP_KERNEL);
raw_capacity = kzalloc_objs(*raw_capacity, num_possible_cpus());
if (!raw_capacity)
return;
+2 -2
View File
@@ -73,7 +73,7 @@ static int regcache_maple_write(struct regmap *map, unsigned int reg,
rcu_read_unlock();
entry = kmalloc_array(last - index + 1, sizeof(*entry), map->alloc_flags);
entry = kmalloc_objs(*entry, last - index + 1, map->alloc_flags);
if (!entry)
return -ENOMEM;
@@ -340,7 +340,7 @@ static int regcache_maple_insert_block(struct regmap *map, int first,
unsigned long *entry;
int i, ret;
entry = kmalloc_array(last - first + 1, sizeof(*entry), map->alloc_flags);
entry = kmalloc_objs(*entry, last - first + 1, map->alloc_flags);
if (!entry)
return -ENOMEM;
+3 -3
View File
@@ -346,9 +346,9 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg)
if (!rbnode->block)
goto err_free;
rbnode->cache_present = kcalloc(BITS_TO_LONGS(rbnode->blklen),
sizeof(*rbnode->cache_present),
map->alloc_flags);
rbnode->cache_present = kzalloc_objs(*rbnode->cache_present,
BITS_TO_LONGS(rbnode->blklen),
map->alloc_flags);
if (!rbnode->cache_present)
goto err_free_block;
+14 -21
View File
@@ -733,50 +733,44 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
return -ENOMEM;
if (chip->num_main_regs) {
d->main_status_buf = kcalloc(chip->num_main_regs,
sizeof(*d->main_status_buf),
GFP_KERNEL);
d->main_status_buf = kzalloc_objs(*d->main_status_buf,
chip->num_main_regs);
if (!d->main_status_buf)
goto err_alloc;
}
d->status_buf = kcalloc(chip->num_regs, sizeof(*d->status_buf),
GFP_KERNEL);
d->status_buf = kzalloc_objs(*d->status_buf, chip->num_regs);
if (!d->status_buf)
goto err_alloc;
if (chip->status_is_level) {
d->prev_status_buf = kcalloc(chip->num_regs, sizeof(*d->prev_status_buf),
GFP_KERNEL);
d->prev_status_buf = kzalloc_objs(*d->prev_status_buf,
chip->num_regs);
if (!d->prev_status_buf)
goto err_alloc;
}
d->mask_buf = kcalloc(chip->num_regs, sizeof(*d->mask_buf),
GFP_KERNEL);
d->mask_buf = kzalloc_objs(*d->mask_buf, chip->num_regs);
if (!d->mask_buf)
goto err_alloc;
d->mask_buf_def = kcalloc(chip->num_regs, sizeof(*d->mask_buf_def),
GFP_KERNEL);
d->mask_buf_def = kzalloc_objs(*d->mask_buf_def, chip->num_regs);
if (!d->mask_buf_def)
goto err_alloc;
if (chip->wake_base) {
d->wake_buf = kcalloc(chip->num_regs, sizeof(*d->wake_buf),
GFP_KERNEL);
d->wake_buf = kzalloc_objs(*d->wake_buf, chip->num_regs);
if (!d->wake_buf)
goto err_alloc;
}
if (chip->type_in_mask) {
d->type_buf_def = kcalloc(chip->num_regs,
sizeof(*d->type_buf_def), GFP_KERNEL);
d->type_buf_def = kzalloc_objs(*d->type_buf_def, chip->num_regs);
if (!d->type_buf_def)
goto err_alloc;
d->type_buf = kcalloc(chip->num_regs, sizeof(*d->type_buf), GFP_KERNEL);
d->type_buf = kzalloc_objs(*d->type_buf, chip->num_regs);
if (!d->type_buf)
goto err_alloc;
}
@@ -785,15 +779,14 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
/*
* Create config_buf[num_config_bases][num_config_regs]
*/
d->config_buf = kcalloc(chip->num_config_bases,
sizeof(*d->config_buf), GFP_KERNEL);
d->config_buf = kzalloc_objs(*d->config_buf,
chip->num_config_bases);
if (!d->config_buf)
goto err_alloc;
for (i = 0; i < chip->num_config_bases; i++) {
d->config_buf[i] = kcalloc(chip->num_config_regs,
sizeof(**d->config_buf),
GFP_KERNEL);
d->config_buf[i] = kzalloc_objs(**d->config_buf,
chip->num_config_regs);
if (!d->config_buf[i])
goto err_alloc;
}
+1 -1
View File
@@ -620,7 +620,7 @@ int bcma_sprom_get(struct bcma_bus *bus)
for (i = 0; i < ARRAY_SIZE(sprom_sizes); i++) {
size_t words = sprom_sizes[i];
sprom = kcalloc(words, sizeof(u16), GFP_KERNEL);
sprom = kzalloc_objs(u16, words);
if (!sprom)
return -ENOMEM;
+1 -2
View File
@@ -473,8 +473,7 @@ static void drbd_calc_cpu_mask(cpumask_var_t *cpu_mask)
{
unsigned int *resources_per_cpu, min_index = ~0;
resources_per_cpu = kcalloc(nr_cpu_ids, sizeof(*resources_per_cpu),
GFP_KERNEL);
resources_per_cpu = kzalloc_objs(*resources_per_cpu, nr_cpu_ids);
if (resources_per_cpu) {
struct drbd_resource *resource;
unsigned int cpu, min = ~0;
+1 -1
View File
@@ -4063,7 +4063,7 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info
return config_unknown_volume(connection, pi);
device = peer_device->device;
p_uuid = kmalloc_array(UI_EXTENDED_SIZE, sizeof(*p_uuid), GFP_NOIO);
p_uuid = kmalloc_objs(*p_uuid, UI_EXTENDED_SIZE, GFP_NOIO);
if (!p_uuid)
return false;
+1 -3
View File
@@ -1043,9 +1043,7 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
goto out_err;
/* ...as well as the array of their sizes. */
snap_sizes = kmalloc_array(snap_count,
sizeof(*header->snap_sizes),
GFP_KERNEL);
snap_sizes = kmalloc_objs(*header->snap_sizes, snap_count);
if (!snap_sizes)
goto out_err;
+1 -2
View File
@@ -448,8 +448,7 @@ static int xlbd_reserve_minors(unsigned int minor, unsigned int nr)
if (end > nr_minors) {
unsigned long *bitmap, *old;
bitmap = kcalloc(BITS_TO_LONGS(end), sizeof(*bitmap),
GFP_KERNEL);
bitmap = kzalloc_objs(*bitmap, BITS_TO_LONGS(end));
if (bitmap == NULL)
return -ENOMEM;
+1 -1
View File
@@ -793,7 +793,7 @@ static struct scatterlist *btintel_pcie_alloc_sgtable(ssize_t size)
return NULL;
nents = DIV_ROUND_UP(size, PAGE_SIZE);
result = kcalloc(nents, sizeof(*result), GFP_KERNEL);
result = kzalloc_objs(*result, nents);
if (!result)
return NULL;
+1 -1
View File
@@ -53,7 +53,7 @@ static void mhi_ep_loopback_ul_callback(struct mhi_ep_device *mhi_dev,
if (!buf)
return;
mhi_ep_lb_work = kmalloc_obj(*mhi_ep_lb_work, GFP_KERNEL);
mhi_ep_lb_work = kmalloc_obj(*mhi_ep_lb_work);
if (!mhi_ep_lb_work) {
kfree(buf);
return;
+1 -2
View File
@@ -2033,8 +2033,7 @@ static unsigned short *ssif_address_list(void)
list_for_each_entry(info, &ssif_infos, link)
count++;
address_list = kcalloc(count + 1, sizeof(*address_list),
GFP_KERNEL);
address_list = kzalloc_objs(*address_list, count + 1);
if (!address_list)
return NULL;
+1 -1
View File
@@ -584,7 +584,7 @@ of_at91_clk_pll_get_characteristics(struct device_node *np)
}
if (num_cells > 3) {
icpll = kcalloc(num_output, sizeof(*icpll), GFP_KERNEL);
icpll = kzalloc_objs(*icpll, num_output);
if (!icpll)
goto out_free_output;
}
+1 -2
View File
@@ -907,8 +907,7 @@ static void __init sam9x7_pmc_setup(struct device_node *np)
u8 num_parents = 4 + sam9x7_gck[i].pp_count;
u32 *mux_table;
mux_table = kmalloc_array(num_parents, sizeof(*mux_table),
GFP_KERNEL);
mux_table = kmalloc_objs(*mux_table, num_parents);
if (!mux_table)
goto err_free;
+2 -4
View File
@@ -1227,8 +1227,7 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
struct clk_hw *tmp_parent_hws[8];
u32 *mux_table;
mux_table = kmalloc_array(num_parents, sizeof(*mux_table),
GFP_KERNEL);
mux_table = kmalloc_objs(*mux_table, num_parents);
if (!mux_table)
goto err_free;
@@ -1328,8 +1327,7 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
struct clk_hw *tmp_parent_hws[8];
u32 *mux_table;
mux_table = kmalloc_array(num_parents, sizeof(*mux_table),
GFP_KERNEL);
mux_table = kmalloc_objs(*mux_table, num_parents);
if (!mux_table)
goto err_free;
+2 -4
View File
@@ -1102,8 +1102,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
struct clk_hw *tmp_parent_hws[8];
u32 *mux_table;
mux_table = kmalloc_array(num_parents, sizeof(*mux_table),
GFP_KERNEL);
mux_table = kmalloc_objs(*mux_table, num_parents);
if (!mux_table)
goto err_free;
@@ -1198,8 +1197,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
struct clk_hw *tmp_parent_hws[8];
u32 *mux_table;
mux_table = kmalloc_array(num_parents, sizeof(*mux_table),
GFP_KERNEL);
mux_table = kmalloc_objs(*mux_table, num_parents);
if (!mux_table)
goto err_free;
+2 -4
View File
@@ -569,14 +569,12 @@ static u32 *parent_process(const char *clocks[],
* selector is not required, but we allocate space for the
* array anyway to keep things simple.
*/
parent_names = kmalloc_array(parent_count, sizeof(*parent_names),
GFP_KERNEL);
parent_names = kmalloc_objs(*parent_names, parent_count);
if (!parent_names)
return ERR_PTR(-ENOMEM);
/* There is at least one parent, so allocate a selector array */
parent_sel = kmalloc_array(parent_count, sizeof(*parent_sel),
GFP_KERNEL);
parent_sel = kmalloc_objs(*parent_sel, parent_count);
if (!parent_sel) {
kfree(parent_names);
+2 -2
View File
@@ -91,7 +91,7 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
count_64 = of_property_count_u64_elems(node, "assigned-clock-rates-u64");
if (count_64 > 0) {
count = count_64;
rates_64 = kcalloc(count, sizeof(*rates_64), GFP_KERNEL);
rates_64 = kzalloc_objs(*rates_64, count);
if (!rates_64)
return -ENOMEM;
@@ -99,7 +99,7 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
"assigned-clock-rates-u64",
rates_64, count);
} else if (count > 0) {
rates = kcalloc(count, sizeof(*rates), GFP_KERNEL);
rates = kzalloc_objs(*rates, count);
if (!rates)
return -ENOMEM;
+1 -2
View File
@@ -332,8 +332,7 @@ static void __init cpg_div6_clock_init(struct device_node *np)
return;
}
parent_names = kmalloc_array(num_parents, sizeof(*parent_names),
GFP_KERNEL);
parent_names = kmalloc_objs(*parent_names, num_parents);
if (!parent_names)
return;
+1 -1
View File
@@ -104,7 +104,7 @@ static unsigned long _sprd_pll_recalc_rate(const struct sprd_pll *pll,
u64 refin;
u16 k1, k2;
cfg = kcalloc(regs_num, sizeof(*cfg), GFP_KERNEL);
cfg = kzalloc_objs(*cfg, regs_num);
if (!cfg)
return parent_rate;
+1 -1
View File
@@ -34,7 +34,7 @@ static void __init sun8i_a23_mbus_setup(struct device_node *node)
void __iomem *reg;
int err;
parents = kcalloc(num_parents, sizeof(*parents), GFP_KERNEL);
parents = kzalloc_objs(*parents, num_parents);
if (!parents)
return;
+1 -1
View File
@@ -559,7 +559,7 @@ tegra_bpmp_clk_register(struct tegra_bpmp *bpmp,
init.num_parents = info->num_parents;
parents = kcalloc(info->num_parents, sizeof(*parents), GFP_KERNEL);
parents = kzalloc_objs(*parents, info->num_parents);
if (!parents)
return ERR_PTR(-ENOMEM);
+1 -2
View File
@@ -212,8 +212,7 @@ void tegra_clk_periph_resume(void)
static int tegra_clk_periph_ctx_init(int banks)
{
periph_state_ctx = kcalloc(2 * banks, sizeof(*periph_state_ctx),
GFP_KERNEL);
periph_state_ctx = kzalloc_objs(*periph_state_ctx, 2 * banks);
if (!periph_state_ctx)
return -ENOMEM;
+1 -2
View File
@@ -273,8 +273,7 @@ static const char **plt_clk_register_parents(struct platform_device *pdev,
if (!data->parents)
return ERR_PTR(-ENOMEM);
parent_names = kcalloc(nparents, sizeof(*parent_names),
GFP_KERNEL);
parent_names = kzalloc_objs(*parent_names, nparents);
if (!parent_names)
return ERR_PTR(-ENOMEM);
+2 -3
View File
@@ -1677,8 +1677,7 @@ static int do_insnlist_ioctl(struct comedi_device *dev,
}
/* Allocate scratch space for all instruction data. */
data = kmalloc_array(max_n_data_required, sizeof(unsigned int),
GFP_KERNEL);
data = kmalloc_objs(unsigned int, max_n_data_required);
if (!data) {
ret = -ENOMEM;
goto error;
@@ -1768,7 +1767,7 @@ static int do_insn_ioctl(struct comedi_device *dev,
n_data = MAX_SAMPLES;
}
data = kmalloc_array(n_data, sizeof(unsigned int), GFP_KERNEL);
data = kmalloc_objs(unsigned int, n_data);
if (!data) {
ret = -ENOMEM;
goto error;
+1 -1
View File
@@ -142,7 +142,7 @@ int comedi_alloc_subdev_readback(struct comedi_subdevice *s)
if (!s->n_chan)
return -EINVAL;
s->readback = kcalloc(s->n_chan, sizeof(*s->readback), GFP_KERNEL);
s->readback = kzalloc_objs(*s->readback, s->n_chan);
if (!s->readback)
return -ENOMEM;
+2 -3
View File
@@ -1024,9 +1024,8 @@ pci224_auto_attach(struct comedi_device *dev, unsigned long context_model)
irq = pci_dev->irq;
/* Allocate buffer to hold values for AO channel scan. */
devpriv->ao_scan_vals = kmalloc_array(board->ao_chans,
sizeof(devpriv->ao_scan_vals[0]),
GFP_KERNEL);
devpriv->ao_scan_vals = kmalloc_objs(devpriv->ao_scan_vals[0],
board->ao_chans);
if (!devpriv->ao_scan_vals)
return -ENOMEM;
+1 -3
View File
@@ -1228,9 +1228,7 @@ static int das1800_attach(struct comedi_device *dev,
if (dev->irq & it->options[2])
das1800_init_dma(dev, it);
devpriv->fifo_buf = kmalloc_array(FIFO_SIZE,
sizeof(*devpriv->fifo_buf),
GFP_KERNEL);
devpriv->fifo_buf = kmalloc_objs(*devpriv->fifo_buf, FIFO_SIZE);
if (!devpriv->fifo_buf)
return -ENOMEM;
+1 -1
View File
@@ -1048,7 +1048,7 @@ static int init_chip_info(void)
cpumask_t *chip_cpu_mask;
int ret = 0;
chip = kcalloc(num_possible_cpus(), sizeof(*chip), GFP_KERNEL);
chip = kzalloc_objs(*chip, num_possible_cpus());
if (!chip)
return -ENOMEM;
+1 -1
View File
@@ -33,7 +33,7 @@ static int pd_parse_state_nodes(
if (ret)
goto free_state;
state_buf = kmalloc(sizeof(u32), GFP_KERNEL);
state_buf = kmalloc_obj(u32);
if (!state_buf) {
ret = -ENOMEM;
goto free_state;
+1 -1
View File
@@ -915,7 +915,7 @@ static int qm_last_regs_init(struct hisi_qm *qm)
if (qm->fun_type == QM_HW_VF)
return 0;
debug->qm_last_words = kcalloc(dfx_regs_num, sizeof(unsigned int), GFP_KERNEL);
debug->qm_last_words = kzalloc_objs(unsigned int, dfx_regs_num);
if (!debug->qm_last_words)
return -ENOMEM;
+1 -2
View File
@@ -3117,8 +3117,7 @@ static int hisi_qp_memory_init(struct hisi_qm *qm, size_t dma_size, int id,
struct hisi_qp *qp;
int ret = -ENOMEM;
qm->poll_data[id].qp_finish_id = kcalloc(qm->qp_num, sizeof(u16),
GFP_KERNEL);
qm->poll_data[id].qp_finish_id = kzalloc_objs(u16, qm->qp_num);
if (!qm->poll_data[id].qp_finish_id)
return -ENOMEM;
@@ -114,8 +114,7 @@ static int tl_calc_count(struct adf_telemetry *telemetry,
int sample_cnt;
int ret = 0;
hist_vals = kmalloc_array(tl_data->num_hbuff, sizeof(*hist_vals),
GFP_KERNEL);
hist_vals = kmalloc_objs(*hist_vals, tl_data->num_hbuff);
if (!hist_vals)
return -ENOMEM;
@@ -171,11 +170,11 @@ static int tl_lat_acc_avg(struct adf_telemetry *telemetry,
u64 *hist_cnt;
int ret = 0;
hist_vals = kmalloc_array(num_hbuff, sizeof(*hist_vals), GFP_KERNEL);
hist_vals = kmalloc_objs(*hist_vals, num_hbuff);
if (!hist_vals)
return -ENOMEM;
hist_cnt = kmalloc_array(num_hbuff, sizeof(*hist_cnt), GFP_KERNEL);
hist_cnt = kmalloc_objs(*hist_cnt, num_hbuff);
if (!hist_cnt) {
ret = -ENOMEM;
goto out_free_hist_vals;
@@ -220,8 +219,7 @@ static int tl_bw_hw_units_to_mbps(struct adf_telemetry *telemetry,
int sample_cnt;
int ret = 0;
hist_vals = kmalloc_array(tl_data->num_hbuff, sizeof(*hist_vals),
GFP_KERNEL);
hist_vals = kmalloc_objs(*hist_vals, tl_data->num_hbuff);
if (!hist_vals)
return -ENOMEM;
@@ -1304,8 +1304,7 @@ int qat_hal_batch_wr_lm(struct icp_qat_fw_loader_handle *handle,
alloc_inst_size = lm_init_header->size;
if ((unsigned int)alloc_inst_size > handle->hal_handle->max_ustore)
alloc_inst_size = handle->hal_handle->max_ustore;
micro_inst_arry = kmalloc_array(alloc_inst_size, sizeof(u64),
GFP_KERNEL);
micro_inst_arry = kmalloc_objs(u64, alloc_inst_size);
if (!micro_inst_arry)
return -ENOMEM;
micro_inst_num = 0;
@@ -373,8 +373,7 @@ static int qat_uclo_init_ustore(struct icp_qat_fw_loader_handle *handle,
u64 *fill_data;
uof_image = image->img_ptr;
fill_data = kcalloc(ICP_QAT_UCLO_MAX_USTORE, sizeof(u64),
GFP_KERNEL);
fill_data = kzalloc_objs(u64, ICP_QAT_UCLO_MAX_USTORE);
if (!fill_data)
return -ENOMEM;
for (i = 0; i < ICP_QAT_UCLO_MAX_USTORE; i++)
@@ -994,8 +993,7 @@ static int qat_uclo_parse_uof_obj(struct icp_qat_fw_loader_handle *handle)
pr_err("UOF incompatible\n");
return -EINVAL;
}
obj_handle->uword_buf = kcalloc(UWORD_CPYBUF_SIZE, sizeof(u64),
GFP_KERNEL);
obj_handle->uword_buf = kzalloc_objs(u64, UWORD_CPYBUF_SIZE);
if (!obj_handle->uword_buf)
return -ENOMEM;
obj_handle->ustore_phy_size = ICP_QAT_UCLO_MAX_USTORE;
+1 -3
View File
@@ -3663,9 +3663,7 @@ static int __init d40_lcla_allocate(struct d40_base *base)
* To full fill this hardware requirement without wasting 256 kb
* we allocate pages until we get an aligned one.
*/
page_list = kmalloc_array(MAX_LCLA_ALLOC_ATTEMPTS,
sizeof(*page_list),
GFP_KERNEL);
page_list = kmalloc_objs(*page_list, MAX_LCLA_ALLOC_ATTEMPTS);
if (!page_list)
return -ENOMEM;
+1 -1
View File
@@ -2186,7 +2186,7 @@ static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev,
if (!nelm)
return info;
tmp = kcalloc(nelm, sizeof(*tmp), GFP_KERNEL);
tmp = kzalloc_objs(*tmp, nelm);
if (!tmp)
return ERR_PTR(-ENOMEM);
+1 -1
View File
@@ -297,7 +297,7 @@ struct zl3073x_pin_props *zl3073x_pin_props_get(struct zl3073x_dev *zldev,
* DPLL core pin properties requires list of frequency ranges.
* So read the frequency list into temporary array.
*/
freqs = kcalloc(num_freqs, sizeof(*freqs), GFP_KERNEL);
freqs = kzalloc_objs(*freqs, num_freqs);
if (!freqs) {
rc = -ENOMEM;
goto err_alloc_freqs;
+1 -2
View File
@@ -363,8 +363,7 @@ int skx_adxl_get(void)
while (*names++)
adxl_component_count++;
adxl_values = kcalloc(adxl_component_count, sizeof(*adxl_values),
GFP_KERNEL);
adxl_values = kzalloc_objs(*adxl_values, adxl_component_count);
if (!adxl_values) {
adxl_component_count = 0;
return -ENOMEM;
+2 -5
View File
@@ -620,9 +620,7 @@ static int scmi_pinctrl_get_group_info(const struct scmi_protocol_handle *ph,
return -ENODATA;
}
group->group_pins = kmalloc_array(group->nr_pins,
sizeof(*group->group_pins),
GFP_KERNEL);
group->group_pins = kmalloc_objs(*group->group_pins, group->nr_pins);
if (!group->group_pins)
return -ENOMEM;
@@ -699,8 +697,7 @@ static int scmi_pinctrl_get_function_info(const struct scmi_protocol_handle *ph,
return -ENODATA;
}
func->groups = kmalloc_array(func->nr_groups, sizeof(*func->groups),
GFP_KERNEL);
func->groups = kmalloc_objs(*func->groups, func->nr_groups);
if (!func->groups)
return -ENOMEM;
+2 -2
View File
@@ -266,7 +266,7 @@ acpi_scmi_dsd_parse_transport_package(struct pcc_transport_map *map,
}
}
p = kzalloc(sizeof(*p), GFP_KERNEL);
p = kzalloc_obj(*p);
if (!p)
return -ENOMEM;
@@ -580,7 +580,7 @@ struct pcc_transport_map *pcc_transport_map_get(struct fwnode_handle *fwnode)
if (map)
return map;
map = kzalloc_obj(*map, GFP_KERNEL);
map = kzalloc_obj(*map);
if (!map)
return ERR_PTR(-ENOMEM);
+5 -5
View File
@@ -293,7 +293,7 @@ static efi_char16_t *coreboot_cfr_efi_name(const char *name)
return ERR_PTR(-ENAMETOOLONG);
efi_char16_t *efi_name __free(kfree) =
kcalloc(len + 1, sizeof(*efi_name), GFP_KERNEL);
kzalloc_objs(*efi_name, len + 1);
if (!efi_name)
return ERR_PTR(-ENOMEM);
@@ -724,8 +724,8 @@ static int coreboot_cfr_copy_bool_values(struct coreboot_cfr_setting *setting)
};
unsigned int i;
setting->values = kcalloc(ARRAY_SIZE(bool_values), sizeof(*setting->values),
GFP_KERNEL);
setting->values = kzalloc_objs(*setting->values,
ARRAY_SIZE(bool_values));
if (!setting->values)
return -ENOMEM;
@@ -779,7 +779,7 @@ static int coreboot_cfr_copy_enum_values(struct coreboot_cfr_setting *setting,
if (count <= 0)
return count ?: -EINVAL;
setting->values = kcalloc(count, sizeof(*setting->values), GFP_KERNEL);
setting->values = kzalloc_objs(*setting->values, count);
if (!setting->values)
return -ENOMEM;
@@ -902,7 +902,7 @@ static int coreboot_cfr_add_numeric_option(struct coreboot_cfr_drvdata *data,
if (option->dependency_id)
return 0;
setting = kzalloc_obj(*setting, GFP_KERNEL);
setting = kzalloc_obj(*setting);
if (!setting)
return -ENOMEM;
+1 -1
View File
@@ -1516,7 +1516,7 @@ int stratix10_svc_async_send(struct stratix10_svc_chan *chan, void *msg,
return -EINVAL;
}
handle = kzalloc(sizeof(*handle), GFP_KERNEL);
handle = kzalloc_obj(*handle);
if (!handle)
return -ENOMEM;
+1 -1
View File
@@ -3759,7 +3759,7 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
return ERR_PTR(sets);
}
sub_types = kcalloc(sets, sizeof(*sub_types), GFP_KERNEL);
sub_types = kzalloc_objs(*sub_types, sets);
if (!sub_types)
return ERR_PTR(-ENOMEM);
+1 -2
View File
@@ -362,8 +362,7 @@ static int __init it87_gpio_init(void)
*/
labels = kcalloc(it87_gpio->chip.ngpio, sizeof("it87_gpXY"),
GFP_KERNEL);
labels_table = kcalloc(it87_gpio->chip.ngpio, sizeof(*labels_table),
GFP_KERNEL);
labels_table = kzalloc_objs(*labels_table, it87_gpio->chip.ngpio);
if (!labels || !labels_table) {
rc = -ENOMEM;
+1 -1
View File
@@ -803,7 +803,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank,
ranges_size = gpio_sim_get_reserved_ranges_size(bank);
if (ranges_size) {
ranges = kcalloc(ranges_size, sizeof(u32), GFP_KERNEL);
ranges = kzalloc_objs(u32, ranges_size);
if (!ranges)
return ERR_PTR(-ENOMEM);
+2 -2
View File
@@ -664,7 +664,7 @@ static int gpiochip_set_names(struct gpio_chip *chip)
return 0;
}
names = kcalloc(count, sizeof(*names), GFP_KERNEL);
names = kzalloc_objs(*names, count);
if (!names)
return -ENOMEM;
@@ -750,7 +750,7 @@ static int gpiochip_apply_reserved_ranges(struct gpio_chip *gc)
if (size == 0)
return 0;
ranges = kmalloc_array(size, sizeof(*ranges), GFP_KERNEL);
ranges = kmalloc_objs(*ranges, size);
if (!ranges)
return -ENOMEM;
+5 -9
View File
@@ -876,21 +876,17 @@ int gpu_buddy_init(struct gpu_buddy *mm, u64 size, u64 chunk_size)
BUG_ON(mm->max_order > GPU_BUDDY_MAX_ORDER);
mm->free_scoreboard = kcalloc(mm->max_order + 1,
sizeof(*mm->free_scoreboard),
GFP_KERNEL);
mm->free_scoreboard = kzalloc_objs(*mm->free_scoreboard,
mm->max_order + 1);
if (!mm->free_scoreboard)
return -ENOMEM;
mm->used_scoreboard = kcalloc(mm->max_order + 1,
sizeof(*mm->used_scoreboard),
GFP_KERNEL);
mm->used_scoreboard = kzalloc_objs(*mm->used_scoreboard,
mm->max_order + 1);
if (!mm->used_scoreboard)
goto out_free_free_scoreboard;
mm->free_tree = kcalloc(mm->max_order + 1,
sizeof(struct rb_root),
GFP_KERNEL);
mm->free_tree = kzalloc_objs(struct rb_root, mm->max_order + 1);
if (!mm->free_tree)
goto out_free_used_scoreboard;
@@ -916,7 +916,7 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,
}
for (i = 0; i <= is_aql; i++) {
attachment[i] = kzalloc(sizeof(*attachment[i]), GFP_KERNEL);
attachment[i] = kzalloc_obj(*attachment[i]);
if (unlikely(!attachment[i])) {
ret = -ENOMEM;
goto unwind;
+1 -1
View File
@@ -1002,7 +1002,7 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf,
if (size & 0x3 || *pos & 0x3)
return -EINVAL;
config = kmalloc_array(256, sizeof(*config), GFP_KERNEL);
config = kmalloc_objs(*config, 256);
if (!config)
return -ENOMEM;
+1 -1
View File
@@ -1162,7 +1162,7 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
goto out_exec;
}
vm_entries = kvcalloc(args->num_entries, sizeof(*vm_entries), GFP_KERNEL);
vm_entries = kvzalloc_objs(*vm_entries, args->num_entries);
if (!vm_entries) {
r = -ENOMEM;
goto out_exec;
+1 -1
View File
@@ -177,7 +177,7 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier,
unsigned long end;
int r;
pfns = kvmalloc_array(npages, sizeof(*pfns), GFP_KERNEL);
pfns = kvmalloc_objs(*pfns, npages);
if (unlikely(!pfns)) {
r = -ENOMEM;
goto out_free_range;
+2 -3
View File
@@ -919,8 +919,7 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
if (ret)
return ret;
regs = kmalloc_array(info->read_mmr_reg.count, sizeof(*regs),
GFP_KERNEL);
regs = kmalloc_objs(*regs, info->read_mmr_reg.count);
if (!regs)
return -ENOMEM;
@@ -1518,7 +1517,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
if (r < 0)
goto pm_put;
fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
fpriv = kzalloc_obj(*fpriv);
if (unlikely(!fpriv)) {
r = -ENOMEM;
goto out_suspend;
+1 -1
View File
@@ -244,7 +244,7 @@ static int amdgpu_check_address_validity(struct amdgpu_device *adev,
(address >= RAS_UMC_INJECT_ADDR_LIMIT))
return -EFAULT;
page_pfns = kcalloc(nr_page_pfns, sizeof(*page_pfns), GFP_KERNEL);
page_pfns = kzalloc_objs(*page_pfns, nr_page_pfns);
if (!page_pfns)
return -ENOMEM;
+9 -9
View File
@@ -1534,10 +1534,10 @@ int ualink_ip_sw_init(struct amdgpu_ip_block *ip_block)
struct amdgpu_device *adev = ip_block->adev;
struct amdgpu_ualink_info *info;
info = kzalloc(sizeof(*info), GFP_KERNEL);
ppod_setup = kzalloc(sizeof(*ppod_setup), GFP_KERNEL);
vpod_config = kzalloc(sizeof(*vpod_config), GFP_KERNEL);
stations = kzalloc(sizeof(*stations), GFP_KERNEL);
info = kzalloc_obj(*info);
ppod_setup = kzalloc_obj(*ppod_setup);
vpod_config = kzalloc_obj(*vpod_config);
stations = kzalloc_obj(*stations);
if (!info || !ppod_setup || !vpod_config || !stations) {
kfree(info);
kfree(ppod_setup);
@@ -3555,7 +3555,7 @@ static void amdgpu_ualink_process_npa_req_msg(struct amdgpu_device *adev,
range_end = 0;
}
mm_node = kzalloc(sizeof(*mm_node), GFP_KERNEL);
mm_node = kzalloc_obj(*mm_node);
if (!mm_node) {
dev_warn(adev->dev,
"NPA-REQ: mm_node alloc failed handle:%llx:%llx\n",
@@ -3926,7 +3926,7 @@ int amdgpu_ualink_import_handle(struct drm_device *dev,
* to the NPA address.
* First store the entry in the Xarray.
*/
imp_xa_node = kzalloc(sizeof(*imp_xa_node), GFP_KERNEL);
imp_xa_node = kzalloc_obj(*imp_xa_node);
if (!imp_xa_node) {
r = -ENOMEM;
goto out;
@@ -4030,7 +4030,7 @@ int amdgpu_ualink_export_handle(struct drm_device *dev, struct drm_file *filp,
/* If no ualink handle generated for BO, then generate one and
* add it to the exporter Xarray.
*/
exp_xa_node = kzalloc(sizeof(*exp_xa_node), GFP_KERNEL);
exp_xa_node = kzalloc_obj(*exp_xa_node);
if (!exp_xa_node) {
dev_err(adev->dev, "Failed to allocate exp_xa_node\n");
r = -ENOMEM;
@@ -5181,7 +5181,7 @@ static int amdgpu_ualink_gart_map(struct amdgpu_device *adev, u64 npages,
dev_dbg(adev->dev, "npa 0x%llx npages 0x%llx\n", npa, npages);
if (npages > 1) {
dma_addr = kmalloc_array(npages, sizeof(*dma_addr), GFP_KERNEL);
dma_addr = kmalloc_objs(*dma_addr, npages);
if (!dma_addr)
return -ENOMEM;
@@ -6328,7 +6328,7 @@ int amdgpu_ualink_sw_init(struct amdgpu_device *adev)
struct amdgpu_ualink_remote *remote;
int r;
remote = kzalloc(sizeof(*remote), GFP_KERNEL);
remote = kzalloc_obj(*remote);
if (!remote)
return -ENOMEM;
adev->ualink.remote = remote;
@@ -505,8 +505,7 @@ int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
syncobj_points = NULL;
}
syncobj = kmalloc_array(num_syncobj_handles, sizeof(*syncobj),
GFP_KERNEL);
syncobj = kmalloc_objs(*syncobj, num_syncobj_handles);
if (!syncobj) {
r = -ENOMEM;
goto free_syncobj_points;
@@ -765,13 +764,11 @@ amdgpu_userq_wait_return_fence_info(struct drm_device *dev, struct drm_file *fil
struct drm_exec exec;
int i, cnt, r;
fence_info = kmalloc_array(wait_info->num_fences, sizeof(*fence_info),
GFP_KERNEL);
fence_info = kmalloc_objs(*fence_info, wait_info->num_fences);
if (!fence_info)
return -ENOMEM;
fences = kmalloc_array(wait_info->num_fences, sizeof(*fences),
GFP_KERNEL);
fences = kmalloc_objs(*fences, wait_info->num_fences);
if (!fences) {
r = -ENOMEM;
goto free_fence_info;
+1 -1
View File
@@ -751,7 +751,7 @@ int soc_v1_0_reset_init(struct amdgpu_device *adev)
{
struct amdgpu_reset_control *reset_ctl;
reset_ctl = kzalloc_obj(*reset_ctl, GFP_KERNEL);
reset_ctl = kzalloc_obj(*reset_ctl);
if (!reset_ctl)
return -ENOMEM;
@@ -1848,8 +1848,8 @@ static int initialize_nocpsch(struct device_queue_manager *dqm)
pr_debug("num of pipes: %d\n", get_pipes_per_mec(dqm));
dqm->allocated_queues = kcalloc(get_pipes_per_mec(dqm),
sizeof(unsigned int), GFP_KERNEL);
dqm->allocated_queues = kzalloc_objs(unsigned int,
get_pipes_per_mec(dqm));
if (!dqm->allocated_queues)
return -ENOMEM;

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