Commit b5f37a0b authored by jianchunfu's avatar jianchunfu Committed by Steven Rostedt (Google)

rtla/utils: Use calloc and check the potential memory allocation failure

Replace malloc with calloc and add memory allocating check
of mon_cpus before used.

Link: https://lkml.kernel.org/r/20220615073348.6891-1-jianchunfu@cmss.chinamobile.com

Fixes: 7d0dc957 ("rtla/timerlat: Add --dma-latency option")
Signed-off-by: default avatarjianchunfu <jianchunfu@cmss.chinamobile.com>
Acked-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 88084a3d
......@@ -106,8 +106,9 @@ int parse_cpu_list(char *cpu_list, char **monitored_cpus)
nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
mon_cpus = malloc(nr_cpus * sizeof(char));
memset(mon_cpus, 0, (nr_cpus * sizeof(char)));
mon_cpus = calloc(nr_cpus, sizeof(char));
if (!mon_cpus)
goto err;
for (p = cpu_list; *p; ) {
cpu = atoi(p);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment