mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 10:33:41 +02:00
perf trace: Avoid an ERR_PTR in syscall_stats
hashmap__new may return an ERR_PTR and previously this would be
assigned to syscall_stats meaning all use of syscall_stats needs to
test for NULL (uninitialized) or an ERR_PTR. Given the only reason
hashmap__new can fail is ENOMEM, just use NULL to indicate the
allocation failure and avoid the code having to test for NULL and
IS_ERR.
Fixes: 96f202eab8 (perf trace: Fix IS_ERR() vs NULL check bug)
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
parent
06ec44c2aa
commit
d05073adda
|
|
@ -1565,7 +1565,9 @@ static bool syscall_id_equal(long key1, long key2, void *ctx __maybe_unused)
|
|||
|
||||
static struct hashmap *alloc_syscall_stats(void)
|
||||
{
|
||||
return hashmap__new(syscall_id_hash, syscall_id_equal, NULL);
|
||||
struct hashmap *result = hashmap__new(syscall_id_hash, syscall_id_equal, NULL);
|
||||
|
||||
return IS_ERR(result) ? NULL : result;
|
||||
}
|
||||
|
||||
static void delete_syscall_stats(struct hashmap *syscall_stats)
|
||||
|
|
@ -1573,7 +1575,7 @@ static void delete_syscall_stats(struct hashmap *syscall_stats)
|
|||
struct hashmap_entry *pos;
|
||||
size_t bkt;
|
||||
|
||||
if (IS_ERR(syscall_stats))
|
||||
if (!syscall_stats)
|
||||
return;
|
||||
|
||||
hashmap__for_each_entry(syscall_stats, pos, bkt)
|
||||
|
|
@ -1589,7 +1591,7 @@ static struct thread_trace *thread_trace__new(struct trace *trace)
|
|||
ttrace->files.max = -1;
|
||||
if (trace->summary) {
|
||||
ttrace->syscall_stats = alloc_syscall_stats();
|
||||
if (IS_ERR(ttrace->syscall_stats))
|
||||
if (!ttrace->syscall_stats)
|
||||
zfree(&ttrace);
|
||||
}
|
||||
}
|
||||
|
|
@ -4464,7 +4466,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 (IS_ERR(trace->syscall_stats))
|
||||
if (!trace->syscall_stats)
|
||||
goto out_delete_evlist;
|
||||
}
|
||||
|
||||
|
|
@ -4771,7 +4773,7 @@ static int trace__replay(struct trace *trace)
|
|||
|
||||
if (trace->summary_mode == SUMMARY__BY_TOTAL) {
|
||||
trace->syscall_stats = alloc_syscall_stats();
|
||||
if (IS_ERR(trace->syscall_stats))
|
||||
if (!trace->syscall_stats)
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user