When using trace-cmd "-e sched:* -R ..." command to set triggers to the all events of given subsystem, trace-cmd fails with a double free error. The problem is in create_event() function, where the config is expanded to the all events. The same "event->trigger" pointer is copied to all events. Later, when the trigger is applied, the update_event() frees this pointer multiple times. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx> --- tracecmd/trace-record.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index ec3bcae9..7dbf599a 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -2702,7 +2702,8 @@ create_event(struct buffer_instance *instance, char *path, struct event_list *ol else free(p); - if (event->trigger) { + if (old_event->trigger) { + event->trigger = strdup(old_event->trigger); ret = asprintf(&p, "%s/trigger", path_dirname); if (ret < 0) die("Failed to allocate trigger path for %s", path); @@ -2883,6 +2884,7 @@ static void expand_event_instance(struct buffer_instance *instance) event = compressed_list; compressed_list = event->next; expand_event(instance, event); + free(event->trigger); free(event); } } -- 2.25.1
![]() |