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 lib/test_workqueue.c (1 of 304 files). Show all
Unified · Split
| @@ -149,11 +149,11 @@ static int __init run_bench(int n_threads, const char *scope, const char *label) · 148 unmodified lines | ||
| 149 | 149 | if (ret) |
| 150 | 150 | return ret; |
| 151 | 151 | |
| 152 | − ctxs = kcalloc(n_threads, sizeof(*ctxs), GFP_KERNEL); | |
| 152 | + ctxs = kzalloc_objs(*ctxs, n_threads); | |
| 153 | 153 | if (!ctxs) |
| 154 | 154 | return -ENOMEM; |
| 155 | 155 | |
| 156 | − tasks = kcalloc(n_threads, sizeof(*tasks), GFP_KERNEL); | |
| 156 | + tasks = kzalloc_objs(*tasks, n_threads); | |
| 157 | 157 | if (!tasks) { |
| 158 | 158 | kfree(ctxs); |
| 159 | 159 | return -ENOMEM; |