* [PATCH] kernel-shark: Handle traces with sched_switch and no sched_waking
@ 2021-09-06 18:50 John Keeping
2021-09-08 12:08 ` Yordan Karadzhov
0 siblings, 1 reply; 2+ messages in thread
From: John Keeping @ 2021-09-06 18:50 UTC (permalink / raw)
To: linux-trace-devel; +Cc: John Keeping
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.
Signed-off-by: John Keeping <john@metanate.com>
---
src/plugins/sched_events.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/plugins/sched_events.c b/src/plugins/sched_events.c
index 83c2520..198ed49 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);
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kernel-shark: Handle traces with sched_switch and no sched_waking
2021-09-06 18:50 [PATCH] kernel-shark: Handle traces with sched_switch and no sched_waking John Keeping
@ 2021-09-08 12:08 ` Yordan Karadzhov
0 siblings, 0 replies; 2+ messages in thread
From: Yordan Karadzhov @ 2021-09-08 12:08 UTC (permalink / raw)
To: John Keeping, linux-trace-devel
On 6.09.21 г. 21:50, John Keeping wrote:
> 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.
>
Very well spotted. Thanks a lot!
Yordan
> Signed-off-by: John Keeping <john@metanate.com>
> ---
> src/plugins/sched_events.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/src/plugins/sched_events.c b/src/plugins/sched_events.c
> index 83c2520..198ed49 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);
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-08 12:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 18:50 [PATCH] kernel-shark: Handle traces with sched_switch and no sched_waking John Keeping
2021-09-08 12:08 ` Yordan Karadzhov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.