diff mbox series

libtracecmd: Fix free_zpage() offset

Message ID 20240111171207.54d7cdbf@gandalf.local.home (mailing list archive)
State Accepted
Commit 1571b67c3ca2e1b6ad5f38559a4c224f710ca4fe
Headers show
Series libtracecmd: Fix free_zpage() offset | expand

Commit Message

Steven Rostedt Jan. 11, 2024, 10:12 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The offset exposed to the callers of libtracecmd is the uncompressed file
offset. The read_zpage() subtracts the fake uncompressed offset to get to
the compressed data offset.

The free_zpage() did not subtract the uncompressed offset so it was not
finding the cached compressed data it was looking for to free, and left the
page not freed.

Subtract the uncompressed file offset from the passed in offset to find the
cached node to free.

Fixes: add83e0c8b511 ("trace-cmd library: Fix tracecmd_read_at()")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-input.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 88bef83f4fe0..e0194f89e5db 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -1384,6 +1384,8 @@  static void free_zpage(struct cpu_data *cpu_data, off_t offset)
 	struct trace_rbtree_node *node;
 	struct zchunk_cache *cache;
 
+	offset -= cpu_data->file_offset;
+
 	node = trace_rbtree_find(&cpu_data->compress.cache, (void *)&offset);
 
 	if (!node)