Skip to content

Commit

Permalink
tracing/histogram: Fix a potential memory leak for kstrdup()
Browse files Browse the repository at this point in the history
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).

Link: https://lkml.kernel.org/r/tencent_C52895FD37802832A3E5B272D05008866F0A@qq.com

Cc: stable@vger.kernel.org
Fixes: d380dcd ("tracing: Fix now invalid var_ref_vals assumption in trace action")
Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
  • Loading branch information
Xiaoke Wang authored and Steven Rostedt (Google) committed Jan 28, 2022
1 parent 4ed308c commit e629e7b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions kernel/trace/trace_events_hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -3935,6 +3935,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;
}
Expand Down

0 comments on commit e629e7b

Please sign in to comment.