Linux Trace Kernel
 help / color / mirror / Atom feed
From: Ella Ma <alansnape3058@gmail.com>
To: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	julia.lawall@inria.fr, Ella Ma <alansnape3058@gmail.com>
Subject: [PATCH] tracing: uprobes: Fix incorrect __free function that frees an error value in __trace_uprobe_create()
Date: Thu, 16 Jul 2026 16:31:54 +0200	[thread overview]
Message-ID: <20260716143154.1091840-1-alansnape3058@gmail.com> (raw)

Before applying the __free annotation, the original version goes to
label `fail_address_parse`, and does not call function
`free_trace_uprobe` on pointer `tu`. However, after the change, the
function will be called whenever the function returns. This makes the
error value returned by `alloc_trace_uprobe` get freed.

This patch fixes this issue by adding the check for error value in the
__free function definition.

Found by Clang Static Analyzer (my own development fork
https://github.com/Snape3058/llvm-patch-revision/tree/cleanup).

	warning: Argument to 'kfree()' is a constant address
	(18446744073709551604), which is not memory allocated by
	'malloc()' [unix.Malloc]

Fixes: 8b658df20658 ("tracing: uprobes: Cleanup __trace_uprobe_create() with __free()")
Signed-off-by: Ella Ma <alansnape3058@gmail.com>
---
 kernel/trace/trace_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index c274346853d1..ccbdc96e5578 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -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 *, if (!IS_ERR_OR_NULL(_T)) free_trace_uprobe(_T))
 
 /*
  * Argument syntax:
-- 
2.34.1


                 reply	other threads:[~2026-07-16 14:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260716143154.1091840-1-alansnape3058@gmail.com \
    --to=alansnape3058@gmail.com \
    --cc=julia.lawall@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox