linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Li Zefan <lizf@cn.fujitsu.com>
Subject: Re: [PATCH 1/2] tracing: Check total refcount before releasing bufs in profile_enable failure
Date: Thu, 8 Oct 2009 23:43:00 +0200	[thread overview]
Message-ID: <20091008214258.GH5073@nowhere> (raw)
In-Reply-To: <19148.1579.573095.98045@cargo.ozlabs.ibm.com>

On Wed, Oct 07, 2009 at 02:08:27PM +1100, Paul Mackerras wrote:
> Frederic Weisbecker writes:
> 
> > When we call the profile_enable() callback of an event, we release the
> > shared perf event tracing buffers unconditionnaly in the failure path.
> > This is wrong because there may be other users of these. Then check the
> > total refcount before doing this.
> 
> [snip]
> 
> > -	kfree(trace_profile_buf_nmi);
> >  fail_buf_nmi:
> > -	kfree(trace_profile_buf);
> > +	if (!total_profile_count) {
> 
> A small problem here: total_profile_count will be 1, not 0, in the
> case where we need to free...
> 
> > +		kfree(trace_profile_buf_nmi);
> > +		kfree(trace_profile_buf);
> > +		trace_profile_buf_nmi = NULL;
> > +		trace_profile_buf = NULL;
> > +	}
> >  fail_buf:
> > -	total_profile_count--;
> 
> since we don't decrement total_profile_count until here.
> 
> Paul.


No, because now we only increment total_profile_count if
nothing has failed. This is even the last thing done
in the succeeded path. So if we fail and need to free, it
means its values is still 0.


  reply	other threads:[~2009-10-08 21:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-01  4:50 Possible bug in ftrace_profile_enable_event Paul Mackerras
2009-10-01  6:20 ` Steven Rostedt
2009-10-02 12:13 ` Frédéric Weisbecker
2009-10-03 13:47 ` [GIT PULL] tracing: Perf tracing fixes Frederic Weisbecker
2009-10-03 13:57   ` Frederic Weisbecker
2009-10-05 17:54   ` Frederic Weisbecker
2009-10-06 12:30     ` Ingo Molnar
2009-10-03 13:47 ` [PATCH 1/2] tracing: Check total refcount before releasing bufs in profile_enable failure Frederic Weisbecker
2009-10-07  3:08   ` Paul Mackerras
2009-10-08 21:43     ` Frederic Weisbecker [this message]
2009-10-08 21:53       ` Paul Mackerras
2009-10-03 13:47 ` [PATCH 2/2] tracing: Use free_percpu instead of kfree Frederic Weisbecker

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=20091008214258.GH5073@nowhere \
    --to=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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).