]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tracing: Use krealloc_array() for trace option array growth
authorYu Peng <pengyu@kylinos.cn>
Tue, 19 May 2026 08:34:09 +0000 (16:34 +0800)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 21 May 2026 22:03:08 +0000 (18:03 -0400)
Use krealloc_array() when growing tr->topts instead of open-coding the
size calculation in krealloc().

This makes the resize path use the helper intended for array allocations
and avoids manual multiplication of the element count and element size.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/20260519083409.3885032-1-pengyu@kylinos.cn
Signed-off-by: Yu Peng <pengyu@kylinos.cn>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace.c

index 6eb4d3097a4d54c84cdfc74e6654272d8a640dfd..aec3f31ed0271c08b49143bd6061ff443a87ccdc 100644 (file)
@@ -7928,8 +7928,8 @@ create_trace_option_files(struct trace_array *tr, struct tracer *tracer,
        if (!topts)
                return 0;
 
-       tr_topts = krealloc(tr->topts, sizeof(*tr->topts) * (tr->nr_topts + 1),
-                           GFP_KERNEL);
+       tr_topts = krealloc_array(tr->topts, tr->nr_topts + 1, sizeof(*tr->topts),
+                                 GFP_KERNEL);
        if (!tr_topts) {
                kfree(topts);
                return -ENOMEM;