linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yordan Karadzhov <y.karadz@gmail.com>
To: John Keeping <john@metanate.com>, linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH] kernel-shark: Handle traces with sched_switch and no sched_waking
Date: Wed, 8 Sep 2021 15:08:32 +0300	[thread overview]
Message-ID: <ebe70744-3ab9-60be-b90c-84d0ad36a03f@gmail.com> (raw)
In-Reply-To: <20210906185005.3130298-1-john@metanate.com>



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);
>   
> 

      reply	other threads:[~2021-09-08 12:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ebe70744-3ab9-60be-b90c-84d0ad36a03f@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=john@metanate.com \
    --cc=linux-trace-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).