提交 46bbe5c6 编写于 作者: T Tom Rix 提交者: Steven Rostedt (VMware)

tracing: fix double free

clang static analyzer reports this problem

trace_events_hist.c:3824:3: warning: Attempt to free
  released memory
    kfree(hist_data->attrs->var_defs.name[i]);

In parse_var_defs() if there is a problem allocating
var_defs.expr, the earlier var_defs.name is freed.
This free is duplicated by free_var_defs() which frees
the rest of the list.

Because free_var_defs() has to run anyway, remove the
second free fom parse_var_defs().

Link: https://lkml.kernel.org/r/20200907135845.15804-1-trix@redhat.com

Cc: stable@vger.kernel.org
Fixes: 30350d65 ("tracing: Add variable support to hist triggers")
Reviewed-by: NTom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: NTom Rix <trix@redhat.com>
Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
上级 54fa9ba5
...@@ -3865,7 +3865,6 @@ static int parse_var_defs(struct hist_trigger_data *hist_data) ...@@ -3865,7 +3865,6 @@ static int parse_var_defs(struct hist_trigger_data *hist_data)
s = kstrdup(field_str, GFP_KERNEL); s = kstrdup(field_str, GFP_KERNEL);
if (!s) { if (!s) {
kfree(hist_data->attrs->var_defs.name[n_vars]);
ret = -ENOMEM; ret = -ENOMEM;
goto free; goto free;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册