Skip to content

Commit c8ca003

Browse files
Chunyu-Hurostedt
authored andcommitted
tracing: Fix return while holding a lock in register_tracer()
commit d39cdd2 ("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: d39cdd2 ("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>
1 parent 6363c6b commit c8ca003

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,10 @@ int __init register_tracer(struct tracer *type)
12561256
if (!type->flags) {
12571257
/*allocate a dummy tracer_flags*/
12581258
type->flags = kmalloc(sizeof(*type->flags), GFP_KERNEL);
1259-
if (!type->flags)
1260-
return -ENOMEM;
1259+
if (!type->flags) {
1260+
ret = -ENOMEM;
1261+
goto out;
1262+
}
12611263
type->flags->val = 0;
12621264
type->flags->opts = dummy_tracer_opt;
12631265
} else

0 commit comments

Comments
 (0)