From: Wander Lairson Costa Date: Mon, 15 Sep 2025 18:10:56 +0000 (-0300) Subject: rtla/actions: Fix condition for buffer reallocation X-Git-Tag: v6.17~6^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2227f273b7dc25a791ae6b152550098aa6934b2f;p=thirdparty%2Fkernel%2Fstable.git rtla/actions: Fix condition for buffer reallocation The condition to check if the actions buffer needs to be resized was incorrect. The check `self->size >= self->len` would evaluate to true on almost every call to `actions_new()`, causing the buffer to be reallocated unnecessarily each time an action was added. Fix the condition to `self->len >= self.size`, ensuring that the buffer is only resized when it is actually full. Cc: John Kacur Cc: Luis Goncalves Cc: Arnaldo Carvalho de Melo Cc: Chang Yin Cc: Costa Shulyupin Cc: Crystal Wood Cc: Gabriele Monaco Link: https://lore.kernel.org/20250915181101.52513-1-wander@redhat.com Fixes: 6ea082b171e00 ("rtla/timerlat: Add action on threshold feature") Signed-off-by: Wander Lairson Costa Reviewed-by: Tomas Glozar Signed-off-by: Steven Rostedt (Google) --- diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/actions.c index eab51c0c0ce2c..13ff1934d47c9 100644 --- a/tools/tracing/rtla/src/actions.c +++ b/tools/tracing/rtla/src/actions.c @@ -49,7 +49,7 @@ actions_destroy(struct actions *self) static struct action * actions_new(struct actions *self) { - if (self->size >= self->len) { + if (self->len >= self->size) { self->size *= 2; self->list = realloc(self->list, self->size * sizeof(struct action)); }