Skip to contentSkip to conversation

tracing/kprobe: Release kprobe print_fmt properly

GIT PULL Steven Rostedt 1 participant 1 message Jul 11, 2018 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

Linus,

This fixes a memory leak in the kprobe code.

Please pull the latest trace-v4.18-rc3-2 tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.18-rc3-2

Tag SHA1: 2dc4f4a15fc23494d3fe5af7e1598923825d5da9 Head SHA1: 0fc8c3581dd42bc8f530314ca86db2d861485731

Jiri Olsa (1):
tracing/kprobe: Release kprobe print_fmt properly

----

 kernel/trace/trace_kprobe.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---------------------------
commit 0fc8c3581dd42bc8f530314ca86db2d861485731
Author: Jiri Olsa <[email protected]>
Date:   Mon Jul 9 16:19:06 2018 +0200

tracing/kprobe: Release kprobe print_fmt properly

We don't release tk->tp.call.print_fmt when destroying local uprobe. Also there's missing print_fmt kfree in create_local_trace_kprobe error path.

Fixes e12f03d7031a ("perf/core: Implement the 'perf_kprobe' PMU")
kernel/trace/trace_kprobe.c +5 -1
index daa81571b22a..21f718472942 100644
@@ -1480,8 +1480,10 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
 	}
 
 	ret = __register_trace_kprobe(tk);
-	if (ret < 0)
+	if (ret < 0) {
+		kfree(tk->tp.call.print_fmt);
 		goto error;
+	}
 
 	return &tk->tp.call;
 error:
@@ -1501,6 +1503,8 @@ void destroy_local_trace_kprobe(struct trace_event_call *event_call)
 	}
 
 	__unregister_trace_kprobe(tk);
+
+	kfree(tk->tp.call.print_fmt);
 	free_trace_kprobe(tk);
 }
 #endif /* CONFIG_PERF_EVENTS */