All of lore.kernel.org
 help / color / mirror / Atom feed
From: Slavomir Kaslev <kaslevs@vmware.com>
To: Yordan Karadzhov <ykaradzhov@vmware.com>
Cc: rostedt@goodmis.org, linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH 2/3] kernel-shark: Fix a memory leak in the sched_events plugin
Date: Tue, 5 Mar 2019 17:56:28 +0200	[thread overview]
Message-ID: <20190305155627.GB19674@box> (raw)
In-Reply-To: <20190305143924.11056-3-ykaradzhov@vmware.com>

On Tue, Mar 05, 2019 at 04:39:23PM +0200, Yordan Karadzhov wrote:
> 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.
> 
> Fixes: 4f392730e ("kernel-shark-qt: Make Sched event plugin use ...")
> Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
> ---
>  kernel-shark/src/plugins/sched_events.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel-shark/src/plugins/sched_events.c b/kernel-shark/src/plugins/sched_events.c
> index 0d6de2d..fe13e6a 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;
> +

Nit: drop the above empty line?

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

Looks good to me.

Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com>

-- Slavi

  reply	other threads:[~2019-03-05 15:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05 14:39 [PATCH 0/3] Improvements and fixes for sched_switch plugin Yordan Karadzhov
2019-03-05 14:39 ` [PATCH 1/3] kernel-shark: Define free_contex function for the sched_events plugin Yordan Karadzhov
2019-03-05 15:54   ` Slavomir Kaslev
2019-03-05 17:11     ` Steven Rostedt
2019-03-05 14:39 ` [PATCH 2/3] kernel-shark: Fix a memory leak in " Yordan Karadzhov
2019-03-05 15:56   ` Slavomir Kaslev [this message]
2019-03-05 17:12     ` Steven Rostedt
2019-03-05 17:07   ` Steven Rostedt
2019-03-05 14:39 ` [PATCH 3/3] kernel-shark: sched_events plugin init with sched_switch events only Yordan Karadzhov
2019-03-05 15:57   ` Slavomir Kaslev
2019-03-05 17:13     ` Steven Rostedt
2019-03-05 17:09   ` Steven Rostedt

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=20190305155627.GB19674@box \
    --to=kaslevs@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=ykaradzhov@vmware.com \
    /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 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.