diff options
author | jianchunfu <jianchunfu@cmss.chinamobile.com> | 2022-06-15 15:33:48 +0800 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-07-11 21:14:29 -0400 |
commit | b5f37a0b6f667f5c72340ca9dcd7703f261cb981 (patch) | |
tree | 1fff9e6a92508b628be5e2ef8d8714370da5b1cf /tools/tracing | |
parent | 88084a3df1672e131ddc1b4e39eeacfd39864acf (diff) | |
download | linux-b5f37a0b6f667f5c72340ca9dcd7703f261cb981.tar.gz |
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: 7d0dc9576dc3 ("rtla/timerlat: Add --dma-latency option")
Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Diffstat (limited to 'tools/tracing')
-rw-r--r-- | tools/tracing/rtla/src/utils.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c index 5352167a1e75..5ae2fa96fde1 100644 --- a/tools/tracing/rtla/src/utils.c +++ b/tools/tracing/rtla/src/utils.c @@ -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); |