aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-trace.c')
-rw-r--r--tools/perf/builtin-trace.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 912fedc5b42d..c88f9f215e6f 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1653,15 +1653,17 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel,
1653 1653
1654 ttrace = thread__priv(thread); 1654 ttrace = thread__priv(thread);
1655 if (!ttrace) 1655 if (!ttrace)
1656 goto out; 1656 goto out_put;
1657 1657
1658 filename_len = strlen(filename); 1658 filename_len = strlen(filename);
1659 if (filename_len == 0)
1660 goto out_put;
1659 1661
1660 if (ttrace->filename.namelen < filename_len) { 1662 if (ttrace->filename.namelen < filename_len) {
1661 char *f = realloc(ttrace->filename.name, filename_len + 1); 1663 char *f = realloc(ttrace->filename.name, filename_len + 1);
1662 1664
1663 if (f == NULL) 1665 if (f == NULL)
1664 goto out; 1666 goto out_put;
1665 1667
1666 ttrace->filename.namelen = filename_len; 1668 ttrace->filename.namelen = filename_len;
1667 ttrace->filename.name = f; 1669 ttrace->filename.name = f;
@@ -1671,12 +1673,12 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel,
1671 ttrace->filename.pending_open = true; 1673 ttrace->filename.pending_open = true;
1672 1674
1673 if (!ttrace->filename.ptr) 1675 if (!ttrace->filename.ptr)
1674 goto out; 1676 goto out_put;
1675 1677
1676 entry_str_len = strlen(ttrace->entry_str); 1678 entry_str_len = strlen(ttrace->entry_str);
1677 remaining_space = trace__entry_str_size - entry_str_len - 1; /* \0 */ 1679 remaining_space = trace__entry_str_size - entry_str_len - 1; /* \0 */
1678 if (remaining_space <= 0) 1680 if (remaining_space <= 0)
1679 goto out; 1681 goto out_put;
1680 1682
1681 if (filename_len > (size_t)remaining_space) { 1683 if (filename_len > (size_t)remaining_space) {
1682 filename += filename_len - remaining_space; 1684 filename += filename_len - remaining_space;
@@ -1690,6 +1692,8 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel,
1690 1692
1691 ttrace->filename.ptr = 0; 1693 ttrace->filename.ptr = 0;
1692 ttrace->filename.entry_str_pos = 0; 1694 ttrace->filename.entry_str_pos = 0;
1695out_put:
1696 thread__put(thread);
1693out: 1697out:
1694 return 0; 1698 return 0;
1695} 1699}
@@ -1710,6 +1714,7 @@ static int trace__sched_stat_runtime(struct trace *trace, struct perf_evsel *evs
1710 1714
1711 ttrace->runtime_ms += runtime_ms; 1715 ttrace->runtime_ms += runtime_ms;
1712 trace->runtime_ms += runtime_ms; 1716 trace->runtime_ms += runtime_ms;
1717out_put:
1713 thread__put(thread); 1718 thread__put(thread);
1714 return 0; 1719 return 0;
1715 1720
@@ -1720,8 +1725,7 @@ out_dump:
1720 (pid_t)perf_evsel__intval(evsel, sample, "pid"), 1725 (pid_t)perf_evsel__intval(evsel, sample, "pid"),
1721 runtime, 1726 runtime,
1722 perf_evsel__intval(evsel, sample, "vruntime")); 1727 perf_evsel__intval(evsel, sample, "vruntime"));
1723 thread__put(thread); 1728 goto out_put;
1724 return 0;
1725} 1729}
1726 1730
1727static void bpf_output__printer(enum binary_printer_ops op, 1731static void bpf_output__printer(enum binary_printer_ops op,
@@ -1920,7 +1924,7 @@ static int trace__process_sample(struct perf_tool *tool,
1920 1924
1921 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); 1925 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
1922 if (thread && thread__is_filtered(thread)) 1926 if (thread && thread__is_filtered(thread))
1923 return 0; 1927 goto out;
1924 1928
1925 trace__set_base_time(trace, evsel, sample); 1929 trace__set_base_time(trace, evsel, sample);
1926 1930
@@ -1928,7 +1932,8 @@ static int trace__process_sample(struct perf_tool *tool,
1928 ++trace->nr_events; 1932 ++trace->nr_events;
1929 handler(trace, evsel, event, sample); 1933 handler(trace, evsel, event, sample);
1930 } 1934 }
1931 1935out:
1936 thread__put(thread);
1932 return err; 1937 return err;
1933} 1938}
1934 1939
@@ -1988,7 +1993,7 @@ static int trace__record(struct trace *trace, int argc, const char **argv)
1988 for (i = 0; i < (unsigned int)argc; i++) 1993 for (i = 0; i < (unsigned int)argc; i++)
1989 rec_argv[j++] = argv[i]; 1994 rec_argv[j++] = argv[i];
1990 1995
1991 return cmd_record(j, rec_argv, NULL); 1996 return cmd_record(j, rec_argv);
1992} 1997}
1993 1998
1994static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp); 1999static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp);
@@ -2786,7 +2791,7 @@ out:
2786 return err; 2791 return err;
2787} 2792}
2788 2793
2789int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) 2794int cmd_trace(int argc, const char **argv)
2790{ 2795{
2791 const char *trace_usage[] = { 2796 const char *trace_usage[] = {
2792 "perf trace [<options>] [<command>]", 2797 "perf trace [<options>] [<command>]",