Linux-Trace-Devel Archive on
 help / color / Atom feed
From: "Tzvetomir Stoyanov (VMware)" <>
Subject: [PATCH 2/3] trace-cmd: Fix double free error when triggers are configured on multiple events
Date: Wed, 25 Mar 2020 16:08:28 +0200
Message-ID: <> (raw)
In-Reply-To: <>

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) <>
 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
-	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);

  parent reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 14:08 [PATCH 0/3] Fix applying triggers to " Tzvetomir Stoyanov (VMware)
2020-03-25 14:08 ` [PATCH 1/3] trace-cmd: Fix check for trigger file in create_event() Tzvetomir Stoyanov (VMware)
2020-03-25 14:08 ` Tzvetomir Stoyanov (VMware) [this message]
2020-03-25 14:08 ` [PATCH 3/3] trace-cmd: Fix setting triggers to all events from given system Tzvetomir Stoyanov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Trace-Devel Archive on

Archives are clonable:
	git clone --mirror linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ \
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone