perf-record: Check correct pid when forking
PATCH 1/1 perf-record: Check correct pid when forking
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.
--- tools/perf/builtin-record.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
tools/perf/builtin-record.c +1 -2
@@ -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 ) {perror ("failed to fork" );exit (-1 ); }
Signature · 6 lines
1.7.1
--
Regards/Gruss,
Boris.Quoted 21 lines · Borislav Petkov
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 <[email protected]>--- tools/perf/builtin-record.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)tools/perf/builtin-record.c +0
-1@@ -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 ;
tools/perf/builtin-record.c static int __cmd_record(int argc, const char **argv) · line 574
Quoted 5 lines
tools/perf/builtin-record.c +1
-1@@ -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 :)
Since I'm preparing some fixes for .35 in perf tools, I'm queuing this one too.
Thanks.
From: Frederic Weisbecker <[email protected]>
Date: Mon, May 31, 2010 at 11:27:26PM +0200
Hi Frederic :),
Quoted 23 lines · Borislav Petkov
Quoted 22 lines
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 <[email protected]>--- tools/perf/builtin-record.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)tools/perf/builtin-record.c +0
-1@@ -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)
Quoted 8 lines
tools/perf/builtin-record.c static int __cmd_record(int argc, const char **argv) · line 574
Quoted 4 lines
tools/perf/builtin-record.c +1
-1if (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 :)
Signature · 2 lines
Regards/Gruss,
Boris.Commit-ID: 2fb750e825b5347de0390315f4284f13709a9856 Gitweb: http://git.kernel.org/tip/2fb750e825b5347de0390315f4284f13709a9856 Author: Borislav Petkov <[email protected]> AuthorDate: Mon, 31 May 2010 23:18:18 +0200 Committer: Frederic Weisbecker <[email protected]> CommitDate: Tue, 1 Jun 2010 00:57:14 +0200
perf-record: Check correct pid when forking
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.
LKML-Reference: <[email protected]>
--- tools/perf/builtin-record.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
tools/perf/builtin-record.c +1 -2
@@ -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 ) {perror ("failed to fork" );exit (-1 ); }