Skip to content

Commit 189f164

Browse files
keestorvalds
authored andcommitted
Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses
Conversion performed via this Coccinelle script: // SPDX-License-Identifier: GPL-2.0-only // Options: --include-headers-for-types --all-includes --include-headers --keep-comments virtual patch @gfp depends on patch && !(file in "tools") && !(file in "samples")@ identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex, kzalloc_obj,kzalloc_objs,kzalloc_flex, kvmalloc_obj,kvmalloc_objs,kvmalloc_flex, kvzalloc_obj,kvzalloc_objs,kvzalloc_flex}; @@ ALLOC(... - , GFP_KERNEL ) $ make coccicheck MODE=patch COCCI=gfp.cocci Build and boot tested x86_64 with Fedora 42's GCC and Clang: Linux version 6.19.0+ (user@host) (gcc (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7), GNU ld version 2.44-12.fc42) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Linux version 6.19.0+ (user@host) (clang version 20.1.8 (Fedora 20.1.8-4.fc42), LLD 20.1.8) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 32a92f8 commit 189f164

415 files changed

Lines changed: 612 additions & 833 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

arch/arm/probes/kprobes/test-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ static int coverage_start_fn(const struct decode_header *h, void *args)
764764
static int coverage_start(const union decode_item *table)
765765
{
766766
coverage.base = kmalloc_objs(struct coverage_entry,
767-
MAX_COVERAGE_ENTRIES, GFP_KERNEL);
767+
MAX_COVERAGE_ENTRIES);
768768
coverage.num_entries = 0;
769769
coverage.nesting = 0;
770770
return table_iter(table, coverage_start_fn, &coverage);

arch/mips/kernel/smp-cps.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
342342
/* Allocate cluster boot configuration structs */
343343
nclusters = mips_cps_numclusters();
344344
mips_cps_cluster_bootcfg = kzalloc_objs(*mips_cps_cluster_bootcfg,
345-
nclusters, GFP_KERNEL);
345+
nclusters);
346346
if (!mips_cps_cluster_bootcfg)
347347
goto err_out;
348348

@@ -368,8 +368,7 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
368368
int v;
369369
core_vpes = core_vpe_count(cl, c);
370370
core_bootcfg[c].vpe_config = kzalloc_objs(*core_bootcfg[c].vpe_config,
371-
core_vpes,
372-
GFP_KERNEL);
371+
core_vpes);
373372
for (v = 0; v < core_vpes; v++)
374373
cpumask_set_cpu(nvpe++, &mips_cps_cluster_bootcfg[cl].cpumask);
375374
if (!core_bootcfg[c].vpe_config)

arch/powerpc/kvm/e500_mmu.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -913,23 +913,20 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
913913
vcpu_e500->gtlb_params[1].sets = 1;
914914

915915
vcpu_e500->gtlb_arch = kmalloc_objs(*vcpu_e500->gtlb_arch,
916-
KVM_E500_TLB0_SIZE + KVM_E500_TLB1_SIZE,
917-
GFP_KERNEL);
916+
KVM_E500_TLB0_SIZE + KVM_E500_TLB1_SIZE);
918917
if (!vcpu_e500->gtlb_arch)
919918
return -ENOMEM;
920919

921920
vcpu_e500->gtlb_offset[0] = 0;
922921
vcpu_e500->gtlb_offset[1] = KVM_E500_TLB0_SIZE;
923922

924923
vcpu_e500->gtlb_priv[0] = kzalloc_objs(struct tlbe_ref,
925-
vcpu_e500->gtlb_params[0].entries,
926-
GFP_KERNEL);
924+
vcpu_e500->gtlb_params[0].entries);
927925
if (!vcpu_e500->gtlb_priv[0])
928926
goto free_vcpu;
929927

930928
vcpu_e500->gtlb_priv[1] = kzalloc_objs(struct tlbe_ref,
931-
vcpu_e500->gtlb_params[1].entries,
932-
GFP_KERNEL);
929+
vcpu_e500->gtlb_params[1].entries);
933930
if (!vcpu_e500->gtlb_priv[1])
934931
goto free_vcpu;
935932

arch/powerpc/perf/imc-pmu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,7 @@ static int imc_mem_init(struct imc_pmu *pmu_ptr, struct device_node *parent,
16991699
/* Needed for hotplug/migration */
17001700
if (!per_nest_pmu_arr) {
17011701
per_nest_pmu_arr = kzalloc_objs(struct imc_pmu *,
1702-
get_max_nest_dev() + 1,
1703-
GFP_KERNEL);
1702+
get_max_nest_dev() + 1);
17041703
if (!per_nest_pmu_arr)
17051704
goto err;
17061705
}

arch/powerpc/platforms/cell/spufs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ static int spufs_switch_log_open(struct inode *inode, struct file *file)
22822282
}
22832283

22842284
ctx->switch_log = kmalloc_flex(*ctx->switch_log, log,
2285-
SWITCH_LOG_BUFSIZE, GFP_KERNEL);
2285+
SWITCH_LOG_BUFSIZE);
22862286

22872287
if (!ctx->switch_log) {
22882288
rc = -ENOMEM;

arch/powerpc/platforms/powernv/opal-async.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ int __init opal_async_comp_init(void)
266266

267267
opal_max_async_tokens = be32_to_cpup(async);
268268
opal_async_tokens = kzalloc_objs(*opal_async_tokens,
269-
opal_max_async_tokens, GFP_KERNEL);
269+
opal_max_async_tokens);
270270
if (!opal_async_tokens) {
271271
err = -ENOMEM;
272272
goto out_opal_node;

arch/powerpc/platforms/pseries/papr_platform_attributes.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ static int __init papr_init(void)
314314
/* Allocate the groups before registering */
315315
for (idx = 0; idx < num_attrs; idx++) {
316316
papr_groups[idx].pg.attrs = kzalloc_objs(*papr_groups[idx].pg.attrs,
317-
KOBJ_MAX_ATTRS + 1,
318-
GFP_KERNEL);
317+
KOBJ_MAX_ATTRS + 1);
319318
if (!papr_groups[idx].pg.attrs)
320319
goto out_pgattrs;
321320

arch/riscv/kernel/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ initialize_relocation_hashtable(unsigned int num_relocations,
754754

755755
/* Number of relocations may be large, so kvmalloc it */
756756
*relocation_hashtable = kvmalloc_objs(**relocation_hashtable,
757-
hashtable_size, GFP_KERNEL);
757+
hashtable_size);
758758
if (!*relocation_hashtable)
759759
return 0;
760760

arch/riscv/kvm/vcpu_sbi_fwft.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static int kvm_sbi_ext_fwft_init(struct kvm_vcpu *vcpu)
353353
int i;
354354

355355
fwft->configs = kzalloc_objs(struct kvm_sbi_fwft_config,
356-
ARRAY_SIZE(features), GFP_KERNEL);
356+
ARRAY_SIZE(features));
357357
if (!fwft->configs)
358358
return -ENOMEM;
359359

arch/s390/kernel/perf_pai.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ static int pai_alloc_cpu(struct perf_event *event, int cpu)
282282
need_paiext_cb = true;
283283
}
284284
cpump->save = kvmalloc_objs(struct pai_userdata,
285-
pai_pmu[idx].num_avail + 1,
286-
GFP_KERNEL);
285+
pai_pmu[idx].num_avail + 1);
287286
if (!cpump->area || !cpump->save ||
288287
(need_paiext_cb && !cpump->paiext_cb)) {
289288
pai_free(mp);

0 commit comments

Comments
 (0)