public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	stable@vger.kernel.org, Tom Zanussi <tom.zanussi@linux.intel.com>,
	Tom Rix <trix@redhat.com>
Subject: [for-linus][PATCH 6/8] tracing: fix double free
Date: Mon, 21 Sep 2020 20:26:26 -0400	[thread overview]
Message-ID: <20200922002700.338682785@goodmis.org> (raw)
In-Reply-To: 20200922002620.231334654@goodmis.org

From: Tom Rix <trix@redhat.com>

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: 30350d65ac56 ("tracing: Add variable support to hist triggers")
Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_hist.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 0b933546142e..1b2ef6490229 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -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;
 			}
-- 
2.28.0



  parent reply	other threads:[~2020-09-22  0:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22  0:26 [for-linus][PATCH 0/8] tracing: Fixes for 5.9 Steven Rostedt
2020-09-22  0:26 ` [for-linus][PATCH 1/8] kprobes: Fix to check probe enabled before disarm_kprobe_ftrace() Steven Rostedt
2020-09-22  0:26 ` [for-linus][PATCH 2/8] ftrace: Free the trampoline when ftrace_startup() fails Steven Rostedt
2020-09-22  0:26 ` [for-linus][PATCH 3/8] ftrace: Fix missing synchronize_rcu() removing trampoline from kallsyms Steven Rostedt
2020-09-22  0:26 ` [for-linus][PATCH 4/8] tracing: Make the space reserved for the pid wider Steven Rostedt
2020-09-22  0:26 ` [for-linus][PATCH 5/8] ftrace: Let ftrace_enable_sysctl take a kernel pointer buffer Steven Rostedt
2020-09-22  0:26 ` Steven Rostedt [this message]
2020-09-22  0:26 ` [for-linus][PATCH 7/8] kprobes: tracing/kprobes: Fix to kill kprobes on initmem after boot Steven Rostedt
2020-09-22  0:26 ` [for-linus][PATCH 8/8] bootconfig: init: make xbc_namebuf static Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200922002700.338682785@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tom.zanussi@linux.intel.com \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox