Skip to content

Commit 8934827

Browse files
committed
Merge tag 'kmalloc_obj-treewide-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull kmalloc_obj conversion from Kees Cook: "This does the tree-wide conversion to kmalloc_obj() and friends using coccinelle, with a subsequent small manual cleanup of whitespace alignment that coccinelle does not handle. This uncovered a clang bug in __builtin_counted_by_ref(), so the conversion is preceded by disabling that for current versions of clang. The imminent clang 22.1 release has the fix. I've done allmodconfig build tests for x86_64, arm64, i386, and arm. I did defconfig builds for alpha, m68k, mips, parisc, powerpc, riscv, s390, sparc, sh, arc, csky, xtensa, hexagon, and openrisc" * tag 'kmalloc_obj-treewide-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: kmalloc_obj: Clean up after treewide replacements treewide: Replace kmalloc with kmalloc_obj for non-scalar types compiler_types: Disable __builtin_counted_by_ref for Clang
2 parents c7decec + 7a70c15 commit 8934827

8,018 files changed

Lines changed: 20062 additions & 20914 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/alpha/kernel/core_marvel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ marvel_agp_setup(alpha_agp_info *agp)
861861
if (!alpha_agpgart_size)
862862
return -ENOMEM;
863863

864-
aper = kmalloc(sizeof(*aper), GFP_KERNEL);
864+
aper = kmalloc_obj(*aper, GFP_KERNEL);
865865
if (aper == NULL) return -ENOMEM;
866866

867867
aper->arena = agp->hose->sg_pci;
@@ -1059,7 +1059,7 @@ marvel_agp_info(void)
10591059
/*
10601060
* Allocate the info structure.
10611061
*/
1062-
agp = kmalloc(sizeof(*agp), GFP_KERNEL);
1062+
agp = kmalloc_obj(*agp, GFP_KERNEL);
10631063
if (!agp)
10641064
return NULL;
10651065

arch/alpha/kernel/core_titan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ titan_agp_setup(alpha_agp_info *agp)
594594
if (!alpha_agpgart_size)
595595
return -ENOMEM;
596596

597-
aper = kmalloc(sizeof(struct titan_agp_aperture), GFP_KERNEL);
597+
aper = kmalloc_obj(struct titan_agp_aperture, GFP_KERNEL);
598598
if (aper == NULL)
599599
return -ENOMEM;
600600

@@ -760,7 +760,7 @@ titan_agp_info(void)
760760
/*
761761
* Allocate the info structure.
762762
*/
763-
agp = kmalloc(sizeof(*agp), GFP_KERNEL);
763+
agp = kmalloc_obj(*agp, GFP_KERNEL);
764764
if (!agp)
765765
return NULL;
766766

arch/alpha/kernel/module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ process_reloc_for_got(Elf64_Rela *rela,
4646
goto found_entry;
4747
}
4848

49-
g = kmalloc (sizeof (*g), GFP_KERNEL);
49+
g = kmalloc_obj(*g, GFP_KERNEL);
5050
g->next = chains[r_sym].next;
5151
g->r_addend = r_addend;
5252
g->got_offset = *poffset;
@@ -93,7 +93,7 @@ module_frob_arch_sections(Elf64_Ehdr *hdr, Elf64_Shdr *sechdrs,
9393
}
9494

9595
nsyms = symtab->sh_size / sizeof(Elf64_Sym);
96-
chains = kcalloc(nsyms, sizeof(struct got_entry), GFP_KERNEL);
96+
chains = kzalloc_objs(struct got_entry, nsyms, GFP_KERNEL);
9797
if (!chains) {
9898
printk(KERN_ERR
9999
"module %s: no memory for symbol chain buffer\n",

arch/alpha/kernel/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static void pdev_save_srm_config(struct pci_dev *dev)
220220
printed = 1;
221221
}
222222

223-
tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
223+
tmp = kmalloc_obj(*tmp, GFP_KERNEL);
224224
if (!tmp) {
225225
printk(KERN_ERR "%s: kmalloc() failed!\n", __func__);
226226
return;

arch/alpha/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ register_cpus(void)
392392
int i;
393393

394394
for_each_possible_cpu(i) {
395-
struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
395+
struct cpu *p = kzalloc_obj(*p, GFP_KERNEL);
396396
if (!p)
397397
return -ENOMEM;
398398
register_cpu(p, i);

arch/arc/kernel/unwind.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void *unwind_add_table(struct module *module, const void *table_start,
366366
if (table_size <= 0)
367367
return NULL;
368368

369-
table = kmalloc(sizeof(*table), GFP_KERNEL);
369+
table = kmalloc_obj(*table, GFP_KERNEL);
370370
if (!table)
371371
return NULL;
372372

arch/arc/net/bpf_jit_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ static int jit_prepare_final_mem_alloc(struct jit_context *ctx)
11401140
}
11411141

11421142
if (ctx->need_extra_pass) {
1143-
ctx->jit_data = kzalloc(sizeof(*ctx->jit_data), GFP_KERNEL);
1143+
ctx->jit_data = kzalloc_obj(*ctx->jit_data, GFP_KERNEL);
11441144
if (!ctx->jit_data)
11451145
return -ENOMEM;
11461146
}

arch/arm/common/locomo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
222222
struct locomo_dev *dev;
223223
int ret;
224224

225-
dev = kzalloc(sizeof(struct locomo_dev), GFP_KERNEL);
225+
dev = kzalloc_obj(struct locomo_dev, GFP_KERNEL);
226226
if (!dev) {
227227
ret = -ENOMEM;
228228
goto out;
@@ -277,7 +277,7 @@ static int locomo_suspend(struct platform_device *dev, pm_message_t state)
277277
struct locomo_save_data *save;
278278
unsigned long flags;
279279

280-
save = kmalloc(sizeof(struct locomo_save_data), GFP_KERNEL);
280+
save = kmalloc_obj(struct locomo_save_data, GFP_KERNEL);
281281
if (!save)
282282
return -ENOMEM;
283283

@@ -360,7 +360,7 @@ __locomo_probe(struct device *me, struct resource *mem, int irq)
360360
unsigned long r;
361361
int i, ret = -ENODEV;
362362

363-
lchip = kzalloc(sizeof(struct locomo), GFP_KERNEL);
363+
lchip = kzalloc_obj(struct locomo, GFP_KERNEL);
364364
if (!lchip)
365365
return -ENOMEM;
366366

arch/arm/common/sa1111.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
737737
unsigned i;
738738
int ret;
739739

740-
dev = kzalloc(sizeof(struct sa1111_dev), GFP_KERNEL);
740+
dev = kzalloc_obj(struct sa1111_dev, GFP_KERNEL);
741741
if (!dev) {
742742
ret = -ENOMEM;
743743
goto err_alloc;
@@ -969,7 +969,7 @@ static int sa1111_suspend_noirq(struct device *dev)
969969
unsigned int val;
970970
void __iomem *base;
971971

972-
save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
972+
save = kmalloc_obj(struct sa1111_save_data, GFP_KERNEL);
973973
if (!save)
974974
return -ENOMEM;
975975
sachip->saved_state = save;

arch/arm/common/scoop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static int scoop_probe(struct platform_device *pdev)
185185
if (!mem)
186186
return -EINVAL;
187187

188-
devptr = kzalloc(sizeof(struct scoop_dev), GFP_KERNEL);
188+
devptr = kzalloc_obj(struct scoop_dev, GFP_KERNEL);
189189
if (!devptr)
190190
return -ENOMEM;
191191

0 commit comments

Comments
 (0)