summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2026-06-24 13:58:33 -0700
committerNamhyung Kim <namhyung@kernel.org>2026-06-30 17:04:51 -0700
commitfcc9159fc82625bf5f8e8fb5fde48709b631bebe (patch)
treece03ae41ad0aaec1b1ecb73f6e302d5803d1281d
parent96a463ee62592b10aa0d96e6bb45de56a981c2d1 (diff)
downloadlinux-stable-fcc9159fc82625bf5f8e8fb5fde48709b631bebe.tar.gz
linux-stable-fcc9159fc82625bf5f8e8fb5fde48709b631bebe.zip
perf timechart: Fix memory leaks in draw_wakeups()
The second loop for per_pidcommd is meaningful only when it doesn't have from and to tasks. Also make sure c->Y is set before copying the comm string otherwise it will be overwritten by next one. Signed-off-by: Namhyung Kim <namhyung@kernel.org>
-rw-r--r--tools/perf/builtin-timechart.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index a73f0ab22fd6..3f9153d5ecfb 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1110,12 +1110,12 @@ static void draw_wakeups(struct timechart *tchart)
c = c->next;
}
c = p->all;
- while (c) {
- if (p->pid == we->waker && !from) {
+ while (c && (!from || !to)) {
+ if (c->Y && p->pid == we->waker && !from) {
from = c->Y;
task_from = strdup(c->comm);
}
- if (p->pid == we->wakee && !to) {
+ if (c->Y && p->pid == we->wakee && !to) {
to = c->Y;
task_to = strdup(c->comm);
}