[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-kernel
Subject:    Re: [PATCH] perf-record: Check correct pid when forking
From:       Borislav Petkov <bp () alien8 ! de>
Date:       2010-05-31 21:40:15
Message-ID: 20100531214015.GA27050 () liondog ! tnic
[Download RAW message or body]

From: Frederic Weisbecker <fweisbec@gmail.com>
Date: Mon, May 31, 2010 at 11:27:26PM +0200

Hi Frederic :),

> On Mon, May 31, 2010 at 11:18:18PM +0200, Borislav Petkov wrote:
> > When forking the child to be traced, we should check the correct return
> > value from fork() and not a local variable which is otherwise unused.
> > 
> > Signed-off-by: Borislav Petkov <bp@alien8.de>
> > ---
> >  tools/perf/builtin-record.c |    3 +--
> >  1 files changed, 1 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> > index 9bc8905..dc3435e 100644
> > --- a/tools/perf/builtin-record.c
> > +++ b/tools/perf/builtin-record.c
> > @@ -503,7 +503,6 @@ static int __cmd_record(int argc, const char **argv)
> >  {
> >  	int i, counter;
> >  	struct stat st;
> > -	pid_t pid = 0;
> >  	int flags;
> >  	int err;
> >  	unsigned long waking = 0;
> > @@ -572,7 +571,7 @@ static int __cmd_record(int argc, const char **argv)
> >  
> >  	if (forks) {
> >  		child_pid = fork();
> > -		if (pid < 0) {
> > +		if (child_pid < 0) {
> 
> 
> 
> Oops :)

Yeah, this looked really odd and I had recheck it couple of times just
to be sure I'm not missing any "hidden" semantics. And it seems that
nobody has hit that because obviously we always fork fine :)

-- 
Regards/Gruss,
    Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic