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.
Showing the changes to kernel/trace/ring_buffer.c (1 of 304 files). Show all
Unified · Split
| @@ -2600,8 +2600,8 @@ rb_allocate_cpu_buffer(struct trace_buffer *buffer, long nr_pages, int cpu) · 2599 unmodified lines | ||
| 2600 | 2600 | cpu_buffer->remote = buffer->remote; |
| 2601 | 2601 | cpu_buffer->meta_page = (struct trace_buffer_meta *)(void *)desc->meta_va; |
| 2602 | 2602 | 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); | |
| 2605 | 2605 | if (!cpu_buffer->subbuf_ids) |
| 2606 | 2606 | goto fail_free_reader; |
| 2607 | 2607 | |