Skip to contentSkip to conversation

Fix segmentation fault in trace-cmd record on invalid event hooks

PATCH Superseded Slavomir Kaslev 1 participant 1 message Oct 24, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix segmentation fault in trace-cmd record on invalid event hooks

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

Invalid hook format 'foobar'
Segmentation fault

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

---
 tracecmd/trace-record.c | 2 ++
 1 file changed, 2 insertions(+)
tracecmd/trace-record.c +2 -0
index c65731f..0596b63 100644
@@ -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;
Signature · 1 line
2.20.1