Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 240dd511 authored by Tom Rix's avatar Tom Rix Committed by Greg Kroah-Hartman
Browse files

tracing: fix double free

commit 46bbe5c671e06f070428b9be142cc4ee5cedebac upstream.

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: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: default avatarTom Rix <trix@redhat.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e794df7b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -4225,7 +4225,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;
			}