linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf trace: Fix IS_ERR() vs NULL check bug
@ 2025-09-17  9:54 Fushuai Wang
  2025-09-17 15:31 ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Fushuai Wang @ 2025-09-17  9:54 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, kan.liang
  Cc: linux-perf-users, linux-kernel, Fushuai Wang

The alloc_syscall_stats() function always returns an error pointer
(ERR_PTR) on failure. So replace NULL check with IS_ERR() check
after calling alloc_syscall_stats() function.

Fixes: fc00897c8a3f ("perf trace: Add --summary-mode option")
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
 tools/perf/builtin-trace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index fe737b3ac6e6..25c41b89f8ab 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -4440,7 +4440,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 
 	if (trace->summary_mode == SUMMARY__BY_TOTAL && !trace->summary_bpf) {
 		trace->syscall_stats = alloc_syscall_stats();
-		if (trace->syscall_stats == NULL)
+		if (IS_ERR(trace->syscall_stats))
 			goto out_delete_evlist;
 	}
 
@@ -4748,7 +4748,7 @@ static int trace__replay(struct trace *trace)
 
 	if (trace->summary_mode == SUMMARY__BY_TOTAL) {
 		trace->syscall_stats = alloc_syscall_stats();
-		if (trace->syscall_stats == NULL)
+		if (IS_ERR(trace->syscall_stats))
 			goto out;
 	}
 
-- 
2.36.1


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

* Re: [PATCH] perf trace: Fix IS_ERR() vs NULL check bug
  2025-09-17  9:54 [PATCH] perf trace: Fix IS_ERR() vs NULL check bug Fushuai Wang
@ 2025-09-17 15:31 ` Ian Rogers
  2025-09-17 16:27   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2025-09-17 15:31 UTC (permalink / raw)
  To: Fushuai Wang
  Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, adrian.hunter, kan.liang, linux-perf-users, linux-kernel

On Wed, Sep 17, 2025 at 2:54 AM Fushuai Wang <wangfushuai@baidu.com> wrote:
>
> The alloc_syscall_stats() function always returns an error pointer
> (ERR_PTR) on failure. So replace NULL check with IS_ERR() check
> after calling alloc_syscall_stats() function.
>
> Fixes: fc00897c8a3f ("perf trace: Add --summary-mode option")
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/builtin-trace.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index fe737b3ac6e6..25c41b89f8ab 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -4440,7 +4440,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>
>         if (trace->summary_mode == SUMMARY__BY_TOTAL && !trace->summary_bpf) {
>                 trace->syscall_stats = alloc_syscall_stats();
> -               if (trace->syscall_stats == NULL)
> +               if (IS_ERR(trace->syscall_stats))
>                         goto out_delete_evlist;
>         }
>
> @@ -4748,7 +4748,7 @@ static int trace__replay(struct trace *trace)
>
>         if (trace->summary_mode == SUMMARY__BY_TOTAL) {
>                 trace->syscall_stats = alloc_syscall_stats();
> -               if (trace->syscall_stats == NULL)
> +               if (IS_ERR(trace->syscall_stats))
>                         goto out;
>         }
>
> --
> 2.36.1
>

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

* Re: [PATCH] perf trace: Fix IS_ERR() vs NULL check bug
  2025-09-17 15:31 ` Ian Rogers
@ 2025-09-17 16:27   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-09-17 16:27 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Fushuai Wang, peterz, mingo, namhyung, mark.rutland,
	alexander.shishkin, jolsa, adrian.hunter, kan.liang,
	linux-perf-users, linux-kernel

On Wed, Sep 17, 2025 at 08:31:02AM -0700, Ian Rogers wrote:
> On Wed, Sep 17, 2025 at 2:54 AM Fushuai Wang <wangfushuai@baidu.com> wrote:
> >
> > The alloc_syscall_stats() function always returns an error pointer
> > (ERR_PTR) on failure. So replace NULL check with IS_ERR() check
> > after calling alloc_syscall_stats() function.
> >
> > Fixes: fc00897c8a3f ("perf trace: Add --summary-mode option")
> > Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
> 
> Reviewed-by: Ian Rogers <irogers@google.com>

Thanks, applied to perf-tools-next,

- Arnaldo

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

end of thread, other threads:[~2025-09-17 16:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17  9:54 [PATCH] perf trace: Fix IS_ERR() vs NULL check bug Fushuai Wang
2025-09-17 15:31 ` Ian Rogers
2025-09-17 16:27   ` Arnaldo Carvalho de Melo

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).