aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov <ykaradzhov@vmware.com>2019-03-05 16:39:23 +0200
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-03-05 12:13:01 -0500
commit3336de24917f8e3334c89606e2c0ff25650eedb5 (patch)
tree6c6054966227acd5c9dc012e57e32a57fd362ae3
parentab266c8253d5737fb292794a9ab235a1de1f722d (diff)
downloadtrace-cmd-3336de24917f8e3334c89606e2c0ff25650eedb5.tar.gz
kernel-shark: Fix a memory leak in the sched_events plugin
When the sched_events plugin fails to initialize not all the memory allocated for the context of the plugin is freed properly. The problem gets fixed by using the free_context helper function defined in the previous patch. Link: http://lore.kernel.org/linux-trace-devel/20190305143924.11056-3-ykaradzhov@vmware.com Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com> Fixes: 4f392730e ("kernel-shark-qt: Make Sched event plugin use its own data collections") Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--kernel-shark/src/plugins/sched_events.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/kernel-shark/src/plugins/sched_events.c b/kernel-shark/src/plugins/sched_events.c
index 0d6de2dc..fe13e6ab 100644
--- a/kernel-shark/src/plugins/sched_events.c
+++ b/kernel-shark/src/plugins/sched_events.c
@@ -74,8 +74,12 @@ static bool plugin_sched_init_context(struct kshark_context *kshark_ctx)
event = tep_find_event_by_name(plugin_ctx->pevent,
"sched", "sched_switch");
- if (!event)
+ if (!event) {
+ plugin_free_context(plugin_ctx);
+ plugin_sched_context_handler = NULL;
+
return false;
+ }
plugin_ctx->sched_switch_event = event;
plugin_ctx->sched_switch_next_field =
@@ -320,11 +324,8 @@ static int plugin_sched_init(struct kshark_context *kshark_ctx)
{
struct plugin_sched_context *plugin_ctx;
- if (!plugin_sched_init_context(kshark_ctx)) {
- free(plugin_sched_context_handler);
- plugin_sched_context_handler = NULL;
+ if (!plugin_sched_init_context(kshark_ctx))
return 0;
- }
plugin_ctx = plugin_sched_context_handler;