@@ -189,19 +189,19 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
189
189
int fd ;
190
190
u64 id ;
191
191
char evt_path [MAXPATHLEN ];
192
- char dir_path [ MAXPATHLEN ] ;
192
+ char * dir_path ;
193
193
194
194
sys_dir = opendir (tracing_events_path );
195
195
if (!sys_dir )
196
196
return NULL ;
197
197
198
198
for_each_subsystem (sys_dir , sys_dirent ) {
199
-
200
- snprintf ( dir_path , MAXPATHLEN , "%s/%s" , tracing_events_path ,
201
- sys_dirent -> d_name ) ;
199
+ dir_path = get_events_file ( sys_dirent -> d_name );
200
+ if (! dir_path )
201
+ continue ;
202
202
evt_dir = opendir (dir_path );
203
203
if (!evt_dir )
204
- continue ;
204
+ goto next ;
205
205
206
206
for_each_event (dir_path , evt_dir , evt_dirent ) {
207
207
@@ -217,6 +217,7 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
217
217
close (fd );
218
218
id = atoll (id_buf );
219
219
if (id == config ) {
220
+ put_events_file (dir_path );
220
221
closedir (evt_dir );
221
222
closedir (sys_dir );
222
223
path = zalloc (sizeof (* path ));
@@ -241,6 +242,8 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
241
242
}
242
243
}
243
244
closedir (evt_dir );
245
+ next :
246
+ put_events_file (dir_path );
244
247
}
245
248
246
249
closedir (sys_dir );
@@ -511,14 +514,19 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,
511
514
struct parse_events_error * err ,
512
515
struct list_head * head_config )
513
516
{
514
- char evt_path [ MAXPATHLEN ] ;
517
+ char * evt_path ;
515
518
struct dirent * evt_ent ;
516
519
DIR * evt_dir ;
517
520
int ret = 0 , found = 0 ;
518
521
519
- snprintf (evt_path , MAXPATHLEN , "%s/%s" , tracing_events_path , sys_name );
522
+ evt_path = get_events_file (sys_name );
523
+ if (!evt_path ) {
524
+ tracepoint_error (err , errno , sys_name , evt_name );
525
+ return -1 ;
526
+ }
520
527
evt_dir = opendir (evt_path );
521
528
if (!evt_dir ) {
529
+ put_events_file (evt_path );
522
530
tracepoint_error (err , errno , sys_name , evt_name );
523
531
return -1 ;
524
532
}
@@ -544,6 +552,7 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,
544
552
ret = -1 ;
545
553
}
546
554
555
+ put_events_file (evt_path );
547
556
closedir (evt_dir );
548
557
return ret ;
549
558
}
@@ -2091,7 +2100,7 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
2091
2100
DIR * sys_dir , * evt_dir ;
2092
2101
struct dirent * sys_dirent , * evt_dirent ;
2093
2102
char evt_path [MAXPATHLEN ];
2094
- char dir_path [ MAXPATHLEN ] ;
2103
+ char * dir_path ;
2095
2104
char * * evt_list = NULL ;
2096
2105
unsigned int evt_i = 0 , evt_num = 0 ;
2097
2106
bool evt_num_known = false;
@@ -2112,11 +2121,12 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
2112
2121
!strglobmatch (sys_dirent -> d_name , subsys_glob ))
2113
2122
continue ;
2114
2123
2115
- snprintf (dir_path , MAXPATHLEN , "%s/%s" , tracing_events_path ,
2116
- sys_dirent -> d_name );
2124
+ dir_path = get_events_file (sys_dirent -> d_name );
2125
+ if (!dir_path )
2126
+ continue ;
2117
2127
evt_dir = opendir (dir_path );
2118
2128
if (!evt_dir )
2119
- continue ;
2129
+ goto next ;
2120
2130
2121
2131
for_each_event (dir_path , evt_dir , evt_dirent ) {
2122
2132
if (event_glob != NULL &&
@@ -2132,11 +2142,15 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
2132
2142
sys_dirent -> d_name , evt_dirent -> d_name );
2133
2143
2134
2144
evt_list [evt_i ] = strdup (evt_path );
2135
- if (evt_list [evt_i ] == NULL )
2145
+ if (evt_list [evt_i ] == NULL ) {
2146
+ put_events_file (dir_path );
2136
2147
goto out_close_evt_dir ;
2148
+ }
2137
2149
evt_i ++ ;
2138
2150
}
2139
2151
closedir (evt_dir );
2152
+ next :
2153
+ put_events_file (dir_path );
2140
2154
}
2141
2155
closedir (sys_dir );
2142
2156
@@ -2184,19 +2198,19 @@ int is_valid_tracepoint(const char *event_string)
2184
2198
DIR * sys_dir , * evt_dir ;
2185
2199
struct dirent * sys_dirent , * evt_dirent ;
2186
2200
char evt_path [MAXPATHLEN ];
2187
- char dir_path [ MAXPATHLEN ] ;
2201
+ char * dir_path ;
2188
2202
2189
2203
sys_dir = opendir (tracing_events_path );
2190
2204
if (!sys_dir )
2191
2205
return 0 ;
2192
2206
2193
2207
for_each_subsystem (sys_dir , sys_dirent ) {
2194
-
2195
- snprintf ( dir_path , MAXPATHLEN , "%s/%s" , tracing_events_path ,
2196
- sys_dirent -> d_name ) ;
2208
+ dir_path = get_events_file ( sys_dirent -> d_name );
2209
+ if (! dir_path )
2210
+ continue ;
2197
2211
evt_dir = opendir (dir_path );
2198
2212
if (!evt_dir )
2199
- continue ;
2213
+ goto next ;
2200
2214
2201
2215
for_each_event (dir_path , evt_dir , evt_dirent ) {
2202
2216
snprintf (evt_path , MAXPATHLEN , "%s:%s" ,
@@ -2208,6 +2222,8 @@ int is_valid_tracepoint(const char *event_string)
2208
2222
}
2209
2223
}
2210
2224
closedir (evt_dir );
2225
+ next :
2226
+ put_events_file (dir_path );
2211
2227
}
2212
2228
closedir (sys_dir );
2213
2229
return 0 ;
0 commit comments