mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tools: perf: util: session.c:  Cleaning up inconsistent NULL checks
@ 2014-05-22 21:58 Rickard Strandqvist
  2014-05-23  7:05 ` Jiri Olsa
  0 siblings, 1 reply; 3+ messages in thread
From: Rickard Strandqvist @ 2014-05-22 21:58 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras
  Cc: Rickard Strandqvist, Ingo Molnar, Arnaldo Carvalho de Melo,
	David Ahern, Jiri Olsa, Adrian Hunter, Namhyung Kim,
	Stephane Eranian, linux-kernel

Cleaning up inconsistent NULL checks.
There is otherwise a risk of a possible null pointer dereference.

Was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 tools/perf/util/session.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 55960f2..8defd80 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1625,13 +1625,15 @@ out_delete_map:
 void perf_session__fprintf_info(struct perf_session *session, FILE *fp,
 				bool full)
 {
-	int fd = perf_data_file__fd(session->file);
+	int fd;
 	struct stat st;
 	int ret;
 
 	if (session == NULL || fp == NULL)
 		return;
 
+	fd = perf_data_file__fd(session->file);
+
 	ret = fstat(fd, &st);
 	if (ret == -1)
 		return;
-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tools: perf: util: session.c:  Cleaning up inconsistent NULL checks
  2014-05-22 21:58 [PATCH] tools: perf: util: session.c: Cleaning up inconsistent NULL checks Rickard Strandqvist
@ 2014-05-23  7:05 ` Jiri Olsa
  2014-05-23 16:47   ` Rickard Strandqvist
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2014-05-23  7:05 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, David Ahern, Adrian Hunter,
	Namhyung Kim, Stephane Eranian, linux-kernel

On Thu, May 22, 2014 at 11:58:36PM +0200, Rickard Strandqvist wrote:
> Cleaning up inconsistent NULL checks.
> There is otherwise a risk of a possible null pointer dereference.
> 
> Was largely found by using a static code analysis program called cppcheck.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  tools/perf/util/session.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 55960f2..8defd80 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -1625,13 +1625,15 @@ out_delete_map:
>  void perf_session__fprintf_info(struct perf_session *session, FILE *fp,
>  				bool full)
>  {
> -	int fd = perf_data_file__fd(session->file);
> +	int fd;
>  	struct stat st;
>  	int ret;
>  
>  	if (session == NULL || fp == NULL)
>  		return;
>  
> +	fd = perf_data_file__fd(session->file);
> +
>  	ret = fstat(fd, &st);
>  	if (ret == -1)
>  		return;
> -- 
> 1.7.10.4
> 
hi,
I merged same patch just a week ago or so ;-)

perf session: Fix possible null pointer dereference in session.c
commit c5765ece8a050836c6255e1276fc8e0e867078da
Author: Masanari Iida <standby24x7@gmail.com>
Date:   Thu May 15 02:13:38 2014 +0900


thanks,
jirka

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tools: perf: util: session.c: Cleaning up inconsistent NULL checks
  2014-05-23  7:05 ` Jiri Olsa
@ 2014-05-23 16:47   ` Rickard Strandqvist
  0 siblings, 0 replies; 3+ messages in thread
From: Rickard Strandqvist @ 2014-05-23 16:47 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, David Ahern, Adrian Hunter,
	Namhyung Kim, Stephane Eranian, linux-kernel

Okay, I wrote a patch with many errors in relation to how you want
your patches on 3 of May. Maybe from there.
But good, then this fix is included :)


Best regards
Rickard Strandqvist


2014-05-23 9:05 GMT+02:00 Jiri Olsa <jolsa@redhat.com>:
> On Thu, May 22, 2014 at 11:58:36PM +0200, Rickard Strandqvist wrote:
>> Cleaning up inconsistent NULL checks.
>> There is otherwise a risk of a possible null pointer dereference.
>>
>> Was largely found by using a static code analysis program called cppcheck.
>>
>> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
>> ---
>>  tools/perf/util/session.c |    4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
>> index 55960f2..8defd80 100644
>> --- a/tools/perf/util/session.c
>> +++ b/tools/perf/util/session.c
>> @@ -1625,13 +1625,15 @@ out_delete_map:
>>  void perf_session__fprintf_info(struct perf_session *session, FILE *fp,
>>                               bool full)
>>  {
>> -     int fd = perf_data_file__fd(session->file);
>> +     int fd;
>>       struct stat st;
>>       int ret;
>>
>>       if (session == NULL || fp == NULL)
>>               return;
>>
>> +     fd = perf_data_file__fd(session->file);
>> +
>>       ret = fstat(fd, &st);
>>       if (ret == -1)
>>               return;
>> --
>> 1.7.10.4
>>
> hi,
> I merged same patch just a week ago or so ;-)
>
> perf session: Fix possible null pointer dereference in session.c
> commit c5765ece8a050836c6255e1276fc8e0e867078da
> Author: Masanari Iida <standby24x7@gmail.com>
> Date:   Thu May 15 02:13:38 2014 +0900
>
>
> thanks,
> jirka

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-23 16:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22 21:58 [PATCH] tools: perf: util: session.c: Cleaning up inconsistent NULL checks Rickard Strandqvist
2014-05-23  7:05 ` Jiri Olsa
2014-05-23 16:47   ` Rickard Strandqvist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome