uprobes: guard trace cleanup against error pointers

Sashiko pointed out the some of the scope cleanups for free_uprobe
could get an error pointer. Handle this case in free_uprobe
to prevent a crash.

On the other hand the macro doesn't need the guard because
free_uprobe itself already does the check.

Link: https://lore.kernel.org/all/20260831150651.1134594-2-ak@kernel.org/

Assisted-by: omp:gpt-5.6-luna sashiko
Signed-off-by: Andi Kleen <ak@kernel.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
This commit is contained in:
Andi Kleen
2026-08-31 08:04:37 -07:00
committed by Masami Hiramatsu (Google)
parent cee9395acd
commit 738ef4cd82

View File

@@ -368,7 +368,7 @@ alloc_trace_uprobe(const char *group, const char *event, int nargs, bool is_ret)
static void free_trace_uprobe(struct trace_uprobe *tu)
{
if (!tu)
if (IS_ERR_OR_NULL(tu))
return;
path_put(&tu->path);
@@ -533,7 +533,7 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
return ret;
}
DEFINE_FREE(free_trace_uprobe, struct trace_uprobe *, if (_T) free_trace_uprobe(_T))
DEFINE_FREE(free_trace_uprobe, struct trace_uprobe *, free_trace_uprobe(_T))
/*
* Argument syntax: