History

tracing/fprobe: Roll back on enable_trace_fprobe() failure

enable_trace_fprobe() sets the file link or the TP_FLAG_PROFILE flag and then registers each trace_fprobe in the probe list. If __register_trace_fprobe() fails partway through, the function returns immediately without unregistering the trace_fprobes it already registered or undoing the file link / flag it set, leaving the event half-enabled and leaking the registered fprobe(s). enable_trace_kprobe() already handles this with a rollback path. Do the same for fprobe: on failure, unregister all probes and clear the file link or profile flag. Link: https://lore.kernel.org/all/20260724064208.480030-1-raushan.jhon@gmail.com/

Raushan Patel committed 3 months ago

Commit aca0cd11 parent 00a8ce21 file · +11 −1Browse files

Unified · Split

kernel/trace/trace_fprobe.c+11−1
@@ -1481,11 +1481,21 @@ static int enable_trace_fprobe(struct trace_event_call *call, · 1480 unmodified lines
14811481 list_for_each_entry(tf, trace_probe_probe_list(tp), tp.list) {
14821482 ret = __register_trace_fprobe(tf);
14831483 if (ret < 0)
1484− return ret;
1484+ goto err;
14851485 }
14861486 }
14871487
14881488 return 0;
1489+
1490+err:
1491+ /* Failed to enable one of them. Roll back all */
1492+ list_for_each_entry(tf, trace_probe_probe_list(tp), tp.list)
1493+ __unregister_trace_fprobe(tf);
1494+ if (file)
1495+ trace_probe_remove_file(tp, file);
1496+ else
1497+ trace_probe_clear_flag(tp, TP_FLAG_PROFILE);
1498+ return ret;
14891499 }
14901500
14911501 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t