path: root/kernel/trace
diff options
authorDan Carpenter <dan.carpenter@oracle.com>2021-08-24 14:51:50 +0300
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2021-09-07 20:58:23 -0400
commit5615e088b43d564aec08ccfaecb21ba484a1b4d6 (patch)
treebb792c38cf876d85e1561b1f04d3ed5f91b7e1cc /kernel/trace
parent54357f0c9149c871e5e4b83ad385a6f2ad3a749f (diff)
tracing: Fix some alloc_event_probe() error handling bugs
There are two bugs in this code. First, if the kzalloc() fails it leads to a NULL dereference of "ep" on the next line. Second, if the alloc_event_probe() function returns an error then it leads to an error pointer dereference in the caller. Link: https://lkml.kernel.org/r/20210824115150.GI31143@kili Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
1 files changed, 3 insertions, 2 deletions
diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
index 56a96e9750cf..3044b762cbd7 100644
--- a/kernel/trace/trace_eprobe.c
+++ b/kernel/trace/trace_eprobe.c
@@ -151,7 +151,7 @@ static struct trace_eprobe *alloc_event_probe(const char *group,
ep = kzalloc(struct_size(ep, tp.args, nargs), GFP_KERNEL);
if (!ep) {
- trace_event_put_ref(ep->event);
+ trace_event_put_ref(event);
goto error;
ep->event = event;
@@ -851,7 +851,8 @@ static int __trace_eprobe_create(int argc, const char *argv[])
ret = PTR_ERR(ep);
/* This must return -ENOMEM, else there is a bug */
- goto error; /* We know ep is not allocated */
+ ep = NULL;
+ goto error;
argc -= 2; argv += 2;

Privacy Policy