提交 c8ca003b 编写于 作者: C Chunyu Hu 提交者: Steven Rostedt

tracing: Fix return while holding a lock in register_tracer()

commit d39cdd20 ("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: d39cdd20 ("tracing: Make tracer_flags use the right set_flag callback")
Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NChunyu Hu <chuhu@redhat.com>
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 6363c6b5
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册