@@ -3240,8 +3240,6 @@ static int perf_sched__lat(struct perf_sched *sched)
3240
3240
3241
3241
static int setup_map_cpus (struct perf_sched * sched )
3242
3242
{
3243
- struct perf_cpu_map * map ;
3244
-
3245
3243
sched -> max_cpu .cpu = sysconf (_SC_NPROCESSORS_CONF );
3246
3244
3247
3245
if (sched -> map .comp ) {
@@ -3250,16 +3248,15 @@ static int setup_map_cpus(struct perf_sched *sched)
3250
3248
return -1 ;
3251
3249
}
3252
3250
3253
- if (! sched -> map .cpus_str )
3254
- return 0 ;
3255
-
3256
- map = perf_cpu_map__new ( sched -> map .cpus_str );
3257
- if (! map ) {
3258
- pr_err ( "failed to get cpus map from %s\n" , sched -> map . cpus_str ) ;
3259
- return -1 ;
3251
+ if (sched -> map .cpus_str ) {
3252
+ sched -> map . cpus = perf_cpu_map__new ( sched -> map . cpus_str ) ;
3253
+ if (! sched -> map . cpus ) {
3254
+ pr_err ( "failed to get cpus map from %s\n" , sched -> map .cpus_str );
3255
+ zfree ( & sched -> map . comp_cpus );
3256
+ return -1 ;
3257
+ }
3260
3258
}
3261
3259
3262
- sched -> map .cpus = map ;
3263
3260
return 0 ;
3264
3261
}
3265
3262
@@ -3299,20 +3296,34 @@ static int setup_color_cpus(struct perf_sched *sched)
3299
3296
3300
3297
static int perf_sched__map (struct perf_sched * sched )
3301
3298
{
3299
+ int rc = -1 ;
3300
+
3302
3301
if (setup_map_cpus (sched ))
3303
- return -1 ;
3302
+ return rc ;
3304
3303
3305
3304
if (setup_color_pids (sched ))
3306
- return -1 ;
3305
+ goto out_put_map_cpus ;
3307
3306
3308
3307
if (setup_color_cpus (sched ))
3309
- return -1 ;
3308
+ goto out_put_color_pids ;
3310
3309
3311
3310
setup_pager ();
3312
3311
if (perf_sched__read_events (sched ))
3313
- return -1 ;
3312
+ goto out_put_color_cpus ;
3313
+
3314
+ rc = 0 ;
3314
3315
print_bad_events (sched );
3315
- return 0 ;
3316
+
3317
+ out_put_color_cpus :
3318
+ perf_cpu_map__put (sched -> map .color_cpus );
3319
+
3320
+ out_put_color_pids :
3321
+ perf_thread_map__put (sched -> map .color_pids );
3322
+
3323
+ out_put_map_cpus :
3324
+ zfree (& sched -> map .comp_cpus );
3325
+ perf_cpu_map__put (sched -> map .cpus );
3326
+ return rc ;
3316
3327
}
3317
3328
3318
3329
static int perf_sched__replay (struct perf_sched * sched )
0 commit comments