Skip to contentSkip to conversation

tracing: Fix error handling in event_hist_trigger_parse

PATCH In review Miaoqian Lin 2 participants 2 messages Dec 11, 2025 – Dec 12, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Fix error handling in event_hist_trigger_parse

Memory allocated with trigger_data_alloc() require trigger_data_free() for proper cleanup.

Replace kfree() with trigger_data_free() to fix this.

Found via static analysis and code review.

Fixes e1f187d09e11 ("tracing: Have existing event_command.parse() implementations use helpers")
---
 kernel/trace/trace_events_hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
index 5e6e70540eef..f9886fff7123 100644
@@ -6902,7 +6902,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
 
 	remove_hist_vars(hist_data);
 
-	kfree(trigger_data);
+	trigger_data_free(trigger_data);
 
 	destroy_hist_data(hist_data);
 	goto out;
Signature · 1 line
2.25.1
maintainer
#1 lore raw

kernel/trace/trace_events_hist.c static int event_hist_trigger_parse(struct event_command *cmd_ops, · line 6908

Quoted 9 lines · On Thu, 11 Dec 2025 14:00:58 +0400 Miaoqian Lin <[email protected]> wrote:
kernel/trace/trace_events_hist.c +1 -1
@@ -6902,7 +6902,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
 
 	remove_hist_vars(hist_data);
 
-	kfree(trigger_data);
+	trigger_data_free(trigger_data);
 
 	destroy_hist_data(hist_data);
 	goto out;

The above code has this:

out_free:

	event_trigger_reset_filter(cmd_ops, trigger_data);

	remove_hist_vars(hist_data);

	kfree(trigger_data);

	destroy_hist_data(hist_data);
	goto out;

Where we have;

void event_trigger_reset_filter(struct event_command *cmd_ops,
struct event_trigger_data *trigger_data)

{
	if (cmd_ops->set_filter)
		cmd_ops->set_filter(NULL, trigger_data, NULL);
}

And trigger_data_free() starts with:

void trigger_data_free(struct event_trigger_data *data)

{
	if (data->cmd_ops->set_filter)
		data->cmd_ops->set_filter(NULL, data, NULL);

thus it looks like the current code is an open coded version of trigger_data_free() without synchronization (as it isn't needed here).

Thus, I believe this is more of a clean up and not a fix (something to go into the next merge window and not the current -rc release).

And the code can be changed to also remove the event_trigger_reset_filter() call.

-- Steve