History

treewide: refresh kmalloc_obj() conversions

This is another run of the Coccinelle script for converting kmalloc() family of allocations to kmalloc_obj() via the existing rules in scripts/coccinelle/api/kmalloc_objs.cocci This catches both the set of kmalloc() uses added since the first kmalloc_obj() conversions in v7.0 and adds a large group missed in the first pass due to Coccinelle not interacting well with the cleanup.h scoped_...() family of macros[1]. I worked around this with spatch's "--macro-file" argument to a file with all the scoped_...() macros mapped to Coccinelle's YACFE_ITERATOR[2] as that was the closest viable control flow indicator I could find. Build tested allmodconfig on x86, arm64, arm, loongarch, mips, powerpc, riscv, and s390 with no new warnings.

Kees Cook committed 2 months ago

Commit 3a2c4d51 parent 90feea3304 files · +637 −726Browse files

Showing the changes to kernel/trace/ring_buffer.c (1 of 304 files). Show all

Unified · Split

kernel/trace/ring_buffer.c+2−2
@@ -2600,8 +2600,8 @@ rb_allocate_cpu_buffer(struct trace_buffer *buffer, long nr_pages, int cpu) · 2599 unmodified lines
26002600 cpu_buffer->remote = buffer->remote;
26012601 cpu_buffer->meta_page = (struct trace_buffer_meta *)(void *)desc->meta_va;
26022602 cpu_buffer->nr_pages = nr_pages;
2603− cpu_buffer->subbuf_ids = kcalloc(cpu_buffer->nr_pages + 1,
2604− sizeof(*cpu_buffer->subbuf_ids), GFP_KERNEL);
2603+ cpu_buffer->subbuf_ids = kzalloc_objs(*cpu_buffer->subbuf_ids,
2604+ cpu_buffer->nr_pages + 1);
26052605 if (!cpu_buffer->subbuf_ids)
26062606 goto fail_free_reader;
26072607