public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@gmail.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>, Namhyung Kim <namhyung.kim@lge.com>,
	Paul Mackerras <paulus@samba.org>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH] hw breakpoint: Fix possible memory leak
Date: Mon, 27 Feb 2012 21:45:42 +0900	[thread overview]
Message-ID: <1330346742.1782.7.camel@leonhard> (raw)
In-Reply-To: <1330340694.11248.64.camel@twins>

2012-02-27 (Mon), 12:04 +0100, Peter Zijlstra wrote:
> On Mon, 2012-02-27 at 11:44 +0100, Ingo Molnar wrote:
> > I edited that code earlier today - is the form below OK, or can 
> > you see a simpler method? It's not yet pushed out so can still 
> > edit it. 
> 
> I think something like the below should do, but then I didn't really
> think much about it, my thoughts went like:
> 
> ... *shees* that's ugly
>   ... that error path already does a loop
>     ... what the problem is!? -- reread changelog
>       ... err_cpu == cpu is placed wrong!
> 
> 
> So I replied and marked read.. waiting to either hear if there's a good
> reason to do ugly or find a new (tested) patch in my inbox.. :-)
> 
> ---
>  kernel/events/hw_breakpoint.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
> index b0309f7..3330022 100644
> --- a/kernel/events/hw_breakpoint.c
> +++ b/kernel/events/hw_breakpoint.c
> @@ -658,10 +658,10 @@ int __init init_hw_breakpoint(void)
>  
>   err_alloc:
>  	for_each_possible_cpu(err_cpu) {
> -		if (err_cpu == cpu)
> -			break;
>  		for (i = 0; i < TYPE_MAX; i++)
>  			kfree(per_cpu(nr_task_bp_pinned[i], cpu));
> +		if (err_cpu == cpu)
> +			break;
>  	}
>  
>  	return -ENOMEM;
> 

This would depend on the initial value of the percpu memory, and thus
have no problem in this case. It looks better to me, too :)


-- 
Regards,
Namhyung Kim



  parent reply	other threads:[~2012-02-27 12:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27  3:02 [PATCH] hw breakpoint: Fix possible memory leak Namhyung Kim
2012-02-27 10:33 ` Peter Zijlstra
2012-02-27 10:44   ` Ingo Molnar
2012-02-27 11:04     ` Peter Zijlstra
2012-02-27 11:56       ` Ingo Molnar
2012-02-27 13:32         ` Namhyung Kim
2012-02-27 19:40           ` Ingo Molnar
2012-02-27 23:38             ` Frederic Weisbecker
2012-02-28  1:19               ` [PATCH v2] hw breakpoint: Fix a " Namhyung Kim
2012-02-28  9:13                 ` [tip:perf/urgent] perf/hwbp: " tip-bot for Namhyung Kim
2012-02-27 12:45       ` Namhyung Kim [this message]
2012-02-27 12:46         ` [PATCH] hw breakpoint: Fix " Peter Zijlstra
2012-02-27 12:50           ` Namhyung Kim

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=1330346742.1782.7.camel@leonhard \
    --to=namhyung@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.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