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
Showing the changes to kernel/trace (1 of 1 file). Show all
Unified · Split
| @@ -1256,8 +1256,10 @@ int __init register_tracer(struct tracer *type) · 1255 unmodified lines | |||
| 1256 | if (!type->flags) { | 1256 | if (!type->flags) { |
| 1257 | /*allocate a dummy tracer_flags*/ | 1257 | /*allocate a dummy tracer_flags*/ |
| 1258 | type->flags = kmalloc(sizeof(*type->flags), GFP_KERNEL); | 1258 | type->flags = kmalloc(sizeof(*type->flags), GFP_KERNEL); |
| 1259 | if (!type->flags) | 1259 | if (!type->flags) { |
| 1260 | return -ENOMEM; | 1260 | ret = -ENOMEM; |
| 1261 | goto out; | ||
| 1262 | } | ||
| 1261 | type->flags->val = 0; | 1263 | type->flags->val = 0; |
| 1262 | type->flags->opts = dummy_tracer_opt; | 1264 | type->flags->opts = dummy_tracer_opt; |
| 1263 | } else | 1265 | } else |