Re: [PATCH v5 5/5] tracing: Adopt __free() and guard() for trace_fprobe.c
From: Steven Rostedt <rostedt@goodmis.org>
Date: 2025-01-08 15:06:13
Also in:
lkml
From: Steven Rostedt <rostedt@goodmis.org>
Date: 2025-01-08 15:06:13
Also in:
lkml
On Wed, 8 Jan 2025 11:11:30 +0900 "Masami Hiramatsu (Google)" [off-list ref] wrote:
@@ -1234,24 +1223,26 @@ static int __trace_fprobe_create(int argc, const char *argv[]) trace_probe_log_err(0, BAD_PROBE_ADDR); else if (ret != -ENOMEM && ret != -EEXIST) trace_probe_log_err(0, FAIL_REG_PROBE); - goto error; - } + ret = -EINVAL; + } else + /* 'tf' is successfully registered. To avoid freeing, assign NULL. */ + tf = NULL; -out: - if (tp_mod) - module_put(tp_mod); + return ret; +} +
Hmm, the above could probably be simplified as:
ret = register_trace_fprobe(tf);
if (ret) {
trace_probe_log_set_index(1);
if (ret == -EILSEQ)
trace_probe_log_err(0, BAD_INSN_BNDRY);
else if (ret == -ENOENT)
trace_probe_log_err(0, BAD_PROBE_ADDR);
else if (ret != -ENOMEM && ret != -EEXIST)
trace_probe_log_err(0, FAIL_REG_PROBE);
return -EINVAL;
}
/* 'tf' is successfully registered. To avoid freeing, assign NULL. */
tf = NULL;
return 0;
}
-- Steve