linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: lumingyindetect@126.com
To: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: rostedt@goodmis.org, mhiramat@kernel.org,
	mathieu.desnoyers@efficios.com,
	LuMingYin <11570291+yin-luming@user.noreply.gitee.com>
Subject: [PATCH] kernel/trace/trace_probe:Fixed memory leak issues in trace_probe.c.
Date: Fri, 26 Apr 2024 10:13:43 +0100	[thread overview]
Message-ID: <20240426091343.1222770-1-lumingyindetect@126.com> (raw)

From: LuMingYin <11570291+yin-luming@user.noreply.gitee.com>

At line 1408 of the file /linux/kernel/trace/trace_probe.c, pointer variables named code and tmp are defined. At line 1437, a new dynamic memory area is allocated using the function kcalloc. When the if statement at line 1467 evaluates to true, the program jumps to the out label at line 1469. Within this function, there are two labels: out and fail. The difference between these two labels is that fail additionally frees the dynamic memory area pointed to by the variable code. Therefore, the program should jump to the fail label instead of the out label. This commit fixes this bug.

Signed-off-by: LuMingYin <11570291+yin-luming@user.noreply.gitee.com>
---
 kernel/trace/trace_probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index dfe3ee6035ec..42bc0f362226 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -1466,7 +1466,7 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,
 		parg->fmt = kmalloc(len, GFP_KERNEL);
 		if (!parg->fmt) {
 			ret = -ENOMEM;
-			goto out;
+			goto fail;
 		}
 		snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype,
 			 parg->count);
-- 
2.25.1


             reply	other threads:[~2024-04-26  9:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26  9:13 lumingyindetect [this message]
2024-04-26 15:18 ` [PATCH] kernel/trace/trace_probe:Fixed memory leak issues in trace_probe.c Masami Hiramatsu
2024-04-26 16:45   ` tracing/probes: Fix a memory leak in traceprobe_parse_probe_arg_body() Markus Elfring
2024-04-26 15:19 ` [PATCH] tracing/probes: Fix memory leak issues " Markus Elfring

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=20240426091343.1222770-1-lumingyindetect@126.com \
    --to=lumingyindetect@126.com \
    --cc=11570291+yin-luming@user.noreply.gitee.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).