Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1361117

[for-next][PATCH 4/8] tracing: Fix return while holding a lock in register_tracer()

From Steven Rostedt <rostedt@goodmis.org>
Newsgroups linux.kernel
Subject [for-next][PATCH 4/8] tracing: Fix return while holding a lock in register_tracer()
Date 2016-03-19 15:20 +0100
Message-ID <repTs-VC-17@gated-at.bofh.it> (permalink)
References <repTr-VC-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Chunyu Hu <chuhu@redhat.com>

commit d39cdd2036a6 ("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.

The issue was found by Dan Carpenter through Smatch static code check tool.

Link: http://lkml.kernel.org/r/1457958941-30265-1-git-send-email-chuhu@redhat.com

Fixes: d39cdd2036a6 ("tracing: Make tracer_flags use the right set_flag callback")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Chunyu Hu <chuhu@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 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 b401a1892dc6..0ae46048f724 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
-- 
2.7.0

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[for-next][PATCH 4/8] tracing: Fix return while holding a lock in register_tracer() Steven Rostedt <rostedt@goodmis.org> - 2016-03-19 15:20 +0100

csiph-web