Linux-Trace-Devel Archive on
 help / color / Atom feed
From: Slavomir Kaslev <>
Subject: [PATCH v2] Fix segmentation fault in trace-cmd record on invalid event hooks
Date: Thu, 24 Oct 2019 15:45:17 +0300
Message-ID: <> (raw)

Currently passing an invalid event hook to trace-cmd record causes a
segmentation fault, e.g.

$ sudo trace-cmd record -e irq -H foobar
  Invalid hook format 'foobar'
  Segmentation fault

Fix this by checking the return value of tracecmd_create_event_hook().

Signed-off-by: Slavomir Kaslev <>
Changes in v2:
 - fixed commit message

 tracecmd/trace-record.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index c65731f..0596b63 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -4632,6 +4632,8 @@ static void add_hook(struct buffer_instance *instance, const char *arg)
 	struct hook_list *hook;

 	hook = tracecmd_create_event_hook(arg);
+	if (!hook)
+		die("Failed to create event hook %s", arg);

 	hook->instance = instance;
 	hook->next = hooks;

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically 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