Re: [PATCH] perf trace: Fix IS_ERR() vs NULL check bug
From: Howard Chu
Date: Sat Feb 28 2026 - 02:07:47 EST
Hi Ian,
On Fri, Feb 27, 2026 at 10:40 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> On Fri, Feb 27, 2026 at 1:32 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> >
> > On Thu, 26 Feb 2026 20:22:08 +0800, wangguangju@xxxxxxxx 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
> > > delete_syscall_stats() function.
> > >
> > >
> > > [...]
> > Applied to perf-tools-next, thanks!
>
> This broke the "perf trace summary" test for me (run `perf test -v`).
> The failing command under gdb shows:
> ```
> $ gdb --args perf trace -s -- true
> ...
> (gdb) r
> ...
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000555555672210 in delete_syscall_stats (syscall_stats=0x0) at
> builtin-trace.c:1579
> 1579 hashmap__for_each_entry(syscall_stats, pos, bkt)
> (gdb) l
> 1574 size_t bkt;
> 1575
> 1576 if (IS_ERR(syscall_stats))
> 1577 return;
> 1578
> 1579 hashmap__for_each_entry(syscall_stats, pos, bkt)
> 1580 zfree(&pos->pvalue);
> 1581 hashmap__free(syscall_stats);
> 1582 }
> ```
>
> As NULL is false for IS_ERR I think the correct change is:
> ```
> if (syscall_stats == NULL || IS_ERR(syscall_stats))
> ```
I suspected the same thing but couldn't find a NULL assignment in the
code, so I rushed the review, I apologize. Yours looks good to me.
Thanks,
Howard
>
> We seem to be routinely breaking tests, which may indicate a lot of
> noise in the test output. I see many failures in the type profiling
> test due to the typedef vs struct issue.
>
> Thanks,
> Ian
>
> > Best regards,
> > Namhyung
> >
> >
>