aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_events.c
diff options
context:
space:
mode:
authorAlexander Z Lam <azl@google.com>2013-07-18 14:18:44 -0400
committerSteven Rostedt <rostedt@goodmis.org>2013-07-18 21:31:30 -0400
commitf77d09a384676bde6445413949d9d2c508ff3e62 (patch)
tree2b3bf03ac95453bdff4d03f20db79f46a647dea6 /kernel/trace/trace_events.c
parent609e85a70bcd0eedf4ec60639dbcfb1ab011e054 (diff)
tracing: Miscellaneous fixes for trace_array ref counting
Some error paths did not handle ref counting properly, and some trace files need ref counting. Link: http://lkml.kernel.org/r/1374171524-11948-1-git-send-email-azl@google.com Cc: stable@vger.kernel.org # 3.10 Cc: Vaibhav Nagarnaik <vnagarnaik@google.com> Cc: David Sharp <dhsharp@google.com> Cc: Alexander Z Lam <lambchop468@gmail.com> Signed-off-by: Alexander Z Lam <azl@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r--kernel/trace/trace_events.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 7d854290bf81..7a75cb22eab7 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1218,6 +1218,7 @@ show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
1218 1218
1219static int ftrace_event_avail_open(struct inode *inode, struct file *file); 1219static int ftrace_event_avail_open(struct inode *inode, struct file *file);
1220static int ftrace_event_set_open(struct inode *inode, struct file *file); 1220static int ftrace_event_set_open(struct inode *inode, struct file *file);
1221static int ftrace_event_release(struct inode *inode, struct file *file);
1221 1222
1222static const struct seq_operations show_event_seq_ops = { 1223static const struct seq_operations show_event_seq_ops = {
1223 .start = t_start, 1224 .start = t_start,
@@ -1245,7 +1246,7 @@ static const struct file_operations ftrace_set_event_fops = {
1245 .read = seq_read, 1246 .read = seq_read,
1246 .write = ftrace_event_write, 1247 .write = ftrace_event_write,
1247 .llseek = seq_lseek, 1248 .llseek = seq_lseek,
1248 .release = seq_release, 1249 .release = ftrace_event_release,
1249}; 1250};
1250 1251
1251static const struct file_operations ftrace_enable_fops = { 1252static const struct file_operations ftrace_enable_fops = {
@@ -1323,6 +1324,15 @@ ftrace_event_open(struct inode *inode, struct file *file,
1323 return ret; 1324 return ret;
1324} 1325}
1325 1326
1327static int ftrace_event_release(struct inode *inode, struct file *file)
1328{
1329 struct trace_array *tr = inode->i_private;
1330
1331 trace_array_put(tr);
1332
1333 return seq_release(inode, file);
1334}
1335
1326static int 1336static int
1327ftrace_event_avail_open(struct inode *inode, struct file *file) 1337ftrace_event_avail_open(struct inode *inode, struct file *file)
1328{ 1338{
@@ -1336,12 +1346,19 @@ ftrace_event_set_open(struct inode *inode, struct file *file)
1336{ 1346{
1337 const struct seq_operations *seq_ops = &show_set_event_seq_ops; 1347 const struct seq_operations *seq_ops = &show_set_event_seq_ops;
1338 struct trace_array *tr = inode->i_private; 1348 struct trace_array *tr = inode->i_private;
1349 int ret;
1350
1351 if (trace_array_get(tr) < 0)
1352 return -ENODEV;
1339 1353
1340 if ((file->f_mode & FMODE_WRITE) && 1354 if ((file->f_mode & FMODE_WRITE) &&
1341 (file->f_flags & O_TRUNC)) 1355 (file->f_flags & O_TRUNC))
1342 ftrace_clear_events(tr); 1356 ftrace_clear_events(tr);
1343 1357
1344 return ftrace_event_open(inode, file, seq_ops); 1358 ret = ftrace_event_open(inode, file, seq_ops);
1359 if (ret < 0)
1360 trace_array_put(tr);
1361 return ret;
1345} 1362}
1346 1363
1347static struct event_subsystem * 1364static struct event_subsystem *