linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chunyu Hu <chuhu@redhat.com>
To: rostedt@goodmis.org
Cc: mingo@redhat.com, dan.carpenter@oracle.com,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] tracing: fix a potential mutex deadlock in register_tracer
Date: Mon, 14 Mar 2016 20:35:41 +0800	[thread overview]
Message-ID: <1457958941-30265-1-git-send-email-chuhu@redhat.com> (raw)

commit d39cdd2036a63eef17a14efbd969405ca5612886 ("tracing: Make
tracer_flags use the right set_flag callback")  introduces a potential
mutex deadlock issue, as it forgets to free the mutex when allocaing
the tracer_flags gets fail. This patch fix the issue. The issue was
found by Dan Carpenter through Smatch static code check tool.

Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
 kernel/trace/trace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index b401a18..0ae4604 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1256,8 +1256,10 @@ int __init register_tracer(struct tracer *type)
 	if (!type->flags) {
 		/*allocate a dummy tracer_flags*/
 		type->flags = kmalloc(sizeof(*type->flags), GFP_KERNEL);
-		if (!type->flags)
-			return -ENOMEM;
+		if (!type->flags) {
+			ret = -ENOMEM;
+			goto out;
+		}
 		type->flags->val = 0;
 		type->flags->opts = dummy_tracer_opt;
 	} else
-- 
1.8.3.1

                 reply	other threads:[~2016-03-14 12:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1457958941-30265-1-git-send-email-chuhu@redhat.com \
    --to=chuhu@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    /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;
as well as URLs for NNTP newsgroup(s).