On Sat, Aug 19, 2023 at 10:11:05AM +0900, Masami Hiramatsu wrote:
SNIP
quoted
quoted
quoted
quoted
quoted
+ func_addr = kallsyms_lookup_name(func);
+ for (i = 0; i < array.size; i++) {
+ struct trace_kprobe *tk_same_name;
+ unsigned long address;
+
+ address = array.addrs[i];
+ /* Skip the function address as we already registered it. */
+ if (address == func_addr)
+ continue;
+
+ /*
+ * alloc_trace_kprobe() first considers symbol name, so we set
+ * this to NULL to allocate this kprobe on the given address.
+ */
+ tk_same_name = alloc_trace_kprobe(KPROBE_EVENT_SYSTEM, event,
+ (void *)address, NULL, offs,
+ 0 /* maxactive */,
+ 0 /* nargs */, is_return);
+
+ if (IS_ERR(tk_same_name)) {
+ ret = -ENOMEM;
+ goto error_free;
+ }
+
+ init_trace_event_call(tk_same_name);
+
+ if (traceprobe_set_print_fmt(&tk_same_name->tp, ptype) < 0) {
+ ret = -ENOMEM;
also are we leaking tk_same_name in here?
quoted
quoted
quoted
quoted
quoted
+ goto error_free;
+ }
+
+ ret = append_trace_kprobe(tk_same_name, tk);
+ if (ret)
and here?
jirka
quoted
quoted
quoted
quoted
quoted
+ goto error_free;
+ }
+
+end:
+ kfree(array.addrs);
return trace_probe_event_call(&tk->tp);
+error_free:
+ kfree(array.addrs);
error:
free_trace_kprobe(tk);
return ERR_PTR(ret);
---
[1]: https://github.com/torvalds/linux/blob/
57012c57536f8814dec92e74197ee96c3498d24e/tools/perf/util/probe-event.c#L29
89- L2993
--
Masami Hiramatsu (Google) [off-list ref]