perf bench numa: Add NULL check after calloc()

Two calloc() calls in the numa benchmark lack NULL return checks,
leading to potential NULL pointer dereferences on allocation failure:

1. worker_process(): the allocated `pthreads` array is used in the
   following for-loop via pthreads[t] without checking for NULL.

2. __bench_numa(): the allocated `pids` array is used in the following
   for-loop via pids[i] without checking for NULL.

Add BUG_ON() checks after each calloc(), consistent with the existing
NULL check style used elsewhere in the same file (e.g., node_present
and nodes allocations).

Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
longlong yan 2026-09-02 15:09:13 +08:00 committed by Arnaldo Carvalho de Melo
parent aa9265d507
commit 2d3135cded

View File

@ -1419,6 +1419,7 @@ static void worker_process(int process_nr)
bind_to_cpumask(td->bind_cpumask);
pthreads = calloc(g->p.nr_threads, sizeof(pthread_t));
BUG_ON(!pthreads);
process_data = setup_private_data(g->p.bytes_process);
if (g->p.show_details >= 3) {
@ -1625,6 +1626,7 @@ static int __bench_numa(const char *name)
return -1;
pids = calloc(g->p.nr_proc, sizeof(*pids));
BUG_ON(!pids);
pid = -1;
if (g->p.serialize_startup) {