aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Keeping <john@metanate.com>2021-09-06 19:50:05 +0100
committerYordan Karadzhov (VMware) <y.karadz@gmail.com>2021-09-08 12:26:02 +0300
commitcadd1a769f95d12d62a25488caab4578bd83ee9a (patch)
tree44dee8609a37bac6d83d090e4cf54c73502cc248
parentc16d184e9432001728efab3038f9e3f2e561f29b (diff)
downloadkernel-shark-cadd1a769f95d12d62a25488caab4578bd83ee9a.tar.gz
kernel-shark: Handle traces with sched_switch and no sched_waking
plugin_sched_init_context() is careful to make the sched_waking (or sched_wakeup{,_new}) event optional but the initializer blindly dereferences plugin_ctx->sched_waking_event which is null if no waking event is found. Add the necessary checks to avoid segfaults when (de)initializing the plugin. Link: https://lore.kernel.org/linux-trace-devel/20210906185005.3130298-1-john@metanate.com Signed-off-by: John Keeping <john@metanate.com> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
-rw-r--r--src/plugins/sched_events.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/plugins/sched_events.c b/src/plugins/sched_events.c
index 83c25208..198ed497 100644
--- a/src/plugins/sched_events.c
+++ b/src/plugins/sched_events.c
@@ -193,9 +193,11 @@ int KSHARK_PLOT_PLUGIN_INITIALIZER(struct kshark_data_stream *stream)
plugin_ctx->sched_switch_event->id,
plugin_sched_swith_action);
- kshark_register_event_handler(stream,
- plugin_ctx->sched_waking_event->id,
- plugin_sched_wakeup_action);
+ if (plugin_ctx->sched_waking_event) {
+ kshark_register_event_handler(stream,
+ plugin_ctx->sched_waking_event->id,
+ plugin_sched_wakeup_action);
+ }
kshark_register_draw_handler(stream, plugin_draw);
@@ -213,9 +215,11 @@ int KSHARK_PLOT_PLUGIN_DEINITIALIZER(struct kshark_data_stream *stream)
plugin_ctx->sched_switch_event->id,
plugin_sched_swith_action);
- kshark_unregister_event_handler(stream,
- plugin_ctx->sched_waking_event->id,
- plugin_sched_wakeup_action);
+ if (plugin_ctx->sched_waking_event) {
+ kshark_unregister_event_handler(stream,
+ plugin_ctx->sched_waking_event->id,
+ plugin_sched_wakeup_action);
+ }
kshark_unregister_draw_handler(stream, plugin_draw);