Skip to content

Commit

Permalink
Merge tag 'trace-rtla-v5.20' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/rostedt/linux-trace

Pull real time analysis tool (rtla) updates from Steven Rostedt:

 - Fix a double free

 - Define syscall numbers for RISCV

 - Fix Makefile when called from -C tools

 - Use calloc() to check for memory allocation failures

* tag 'trace-rtla-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  rtla: Define syscall numbers for riscv
  rtla: Fix double free
  rtla: Fix Makefile when called from -C tools/
  rtla/utils: Use calloc and check the potential memory allocation failure
  • Loading branch information
torvalds committed Aug 5, 2022
2 parents b2a88c2 + dd0b15b commit 29b1d46
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tools/tracing/rtla/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NAME := rtla
# Follow the kernel version
VERSION := $(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion)
VERSION := $(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion | grep -v make)

# From libtracefs:
# Makefiles suck: This macro sets a default value of $(2) for the
Expand Down
9 changes: 7 additions & 2 deletions tools/tracing/rtla/src/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,18 @@ void trace_instance_destroy(struct trace_instance *trace)
if (trace->inst) {
disable_tracer(trace->inst);
destroy_instance(trace->inst);
trace->inst = NULL;
}

if (trace->seq)
if (trace->seq) {
free(trace->seq);
trace->seq = NULL;
}

if (trace->tep)
if (trace->tep) {
tep_free(trace->tep);
trace->tep = NULL;
}
}

/*
Expand Down
7 changes: 4 additions & 3 deletions tools/tracing/rtla/src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -224,7 +225,7 @@ long parse_ns_duration(char *val)
#elif __arm__
# define __NR_sched_setattr 380
# define __NR_sched_getattr 381
#elif __aarch64__
#elif __aarch64__ || __riscv
# define __NR_sched_setattr 274
# define __NR_sched_getattr 275
#elif __powerpc__
Expand Down

0 comments on commit 29b1d46

Please sign in to comment.