]> Git Repo - linux.git/commitdiff
tracing: fix double free
authorTom Rix <[email protected]>
Mon, 7 Sep 2020 13:58:45 +0000 (06:58 -0700)
committerSteven Rostedt (VMware) <[email protected]>
Fri, 18 Sep 2020 17:16:40 +0000 (13:16 -0400)
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/[email protected]
Cc: [email protected]
Fixes: 30350d65ac56 ("tracing: Add variable support to hist triggers")
Reviewed-by: Tom Zanussi <[email protected]>
Signed-off-by: Tom Rix <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
kernel/trace/trace_events_hist.c

index 0b933546142e8b371bf42550d3c0026dfdd5128b..1b2ef64902296bd4def5f482a6539946100f460c 100644 (file)
@@ -3865,7 +3865,6 @@ static int parse_var_defs(struct hist_trigger_data *hist_data)
 
                        s = kstrdup(field_str, GFP_KERNEL);
                        if (!s) {
-                               kfree(hist_data->attrs->var_defs.name[n_vars]);
                                ret = -ENOMEM;
                                goto free;
                        }
This page took 0.094948 seconds and 4 git commands to generate.