summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Peng <pengyu@kylinos.cn>2026-05-19 11:34:09 +0300
committerSteven Rostedt <rostedt@goodmis.org>2026-05-22 01:03:08 +0300
commit153498f200d295f3efa6bd37fc6e7ff105ab344f (patch)
treea53e1e4b040ab3bc8640fbb9236798229a24c729
parent5ec75d6a1b5b8beebea3bcaa85baad295ee09dcb (diff)
downloadlinux-153498f200d295f3efa6bd37fc6e7ff105ab344f.tar.xz
tracing: Use krealloc_array() for trace option array growth
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>
-rw-r--r--kernel/trace/trace.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6eb4d3097a4d..aec3f31ed027 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -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;