Skip to content

Commit b5f37a0

Browse files
jianchunfurostedt
authored andcommitted
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/[email protected] Fixes: 7d0dc95 ("rtla/timerlat: Add --dma-latency option") Signed-off-by: jianchunfu <[email protected]> Acked-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 88084a3 commit b5f37a0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/tracing/rtla/src/utils.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ int parse_cpu_list(char *cpu_list, char **monitored_cpus)
106106

107107
nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
108108

109-
mon_cpus = malloc(nr_cpus * sizeof(char));
110-
memset(mon_cpus, 0, (nr_cpus * sizeof(char)));
109+
mon_cpus = calloc(nr_cpus, sizeof(char));
110+
if (!mon_cpus)
111+
goto err;
111112

112113
for (p = cpu_list; *p; ) {
113114
cpu = atoi(p);

0 commit comments

Comments
 (0)