diff options
author | Alexander Z Lam <azl@google.com> | 2013-07-18 14:18:44 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2013-07-18 21:31:30 -0400 |
commit | f77d09a384676bde6445413949d9d2c508ff3e62 (patch) | |
tree | 2b3bf03ac95453bdff4d03f20db79f46a647dea6 /kernel/trace/trace_events.c | |
parent | 609e85a70bcd0eedf4ec60639dbcfb1ab011e054 (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.c | 21 |
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 | ||
1219 | static int ftrace_event_avail_open(struct inode *inode, struct file *file); | 1219 | static int ftrace_event_avail_open(struct inode *inode, struct file *file); |
1220 | static int ftrace_event_set_open(struct inode *inode, struct file *file); | 1220 | static int ftrace_event_set_open(struct inode *inode, struct file *file); |
1221 | static int ftrace_event_release(struct inode *inode, struct file *file); | ||
1221 | 1222 | ||
1222 | static const struct seq_operations show_event_seq_ops = { | 1223 | static 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 | ||
1251 | static const struct file_operations ftrace_enable_fops = { | 1252 | static 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 | ||
1327 | static 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 | |||
1326 | static int | 1336 | static int |
1327 | ftrace_event_avail_open(struct inode *inode, struct file *file) | 1337 | ftrace_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 | ||
1347 | static struct event_subsystem * | 1364 | static struct event_subsystem * |