Add memory allocating check of mon_cpus before used in utils. Signed-off-by: jianchunfu <jianchunfu@xxxxxxxxxxxxxxxxxxxx> --- tools/tracing/rtla/src/utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c index ffaf8ec84..2a86440b3 100644 --- a/tools/tracing/rtla/src/utils.c +++ b/tools/tracing/rtla/src/utils.c @@ -106,6 +106,10 @@ int parse_cpu_list(char *cpu_list, char **monitored_cpus) nr_cpus = sysconf(_SC_NPROCESSORS_CONF); mon_cpus = malloc(nr_cpus * sizeof(char)); + if (!mon_cpus) { + perror("Failed to allocate memory"); + return -errno; + } memset(mon_cpus, 0, (nr_cpus * sizeof(char))); for (p = cpu_list; *p; ) { -- 2.18.4