]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rtla/actions: Fix condition for buffer reallocation
authorWander Lairson Costa <wander@redhat.com>
Mon, 15 Sep 2025 18:10:56 +0000 (15:10 -0300)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Sat, 27 Sep 2025 10:01:20 +0000 (06:01 -0400)
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 <jkacur@redhat.com>
Cc: Luis Goncalves <lgoncalv@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Chang Yin <cyin@redhat.com>
Cc: Costa Shulyupin <costa.shul@redhat.com>
Cc: Crystal Wood <crwood@redhat.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
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 <wander@redhat.com>
Reviewed-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
tools/tracing/rtla/src/actions.c

index eab51c0c0ce2c9fab998c06c6569224ac2951913..13ff1934d47c94f414c636afaf687f75a36618d3 100644 (file)
@@ -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));
        }