[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_C52895FD37802832A3E5B272D05008866F0A@qq.com>
Date: Tue, 25 Jan 2022 12:07:15 +0800
From: xkernel.wang@...mail.com
To: rostedt@...dmis.org, mingo@...hat.com
Cc: linux-kernel@...r.kernel.org,
Xiaoke Wang <xkernel.wang@...mail.com>
Subject: [PATCH] tracing/histogram: fix a potential memory leak for kstrdup()
From: Xiaoke Wang <xkernel.wang@...mail.com>
kfree() is missing on an error path to free the memory allocated by
kstrdup():
> p = param = kstrdup(data->params[i], GFP_KERNEL);
So it is better to free it via kfree(p).
Signed-off-by: Xiaoke Wang <xkernel.wang@...mail.com>
---
kernel/trace/trace_events_hist.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index f01e442..1fac14c 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -3578,6 +3578,7 @@ static int trace_action_create(struct hist_trigger_data *hist_data,
var_ref_idx = find_var_ref_idx(hist_data, var_ref);
if (WARN_ON(var_ref_idx < 0)) {
+ kfree(p);
ret = var_ref_idx;
goto err;
}
--
Powered by blists - more mailing lists