@@ -3252,8 +3252,6 @@ static int perf_sched__lat(struct perf_sched *sched)
3252
3252
3253
3253
static int setup_map_cpus (struct perf_sched * sched )
3254
3254
{
3255
- struct perf_cpu_map * map ;
3256
-
3257
3255
sched -> max_cpu .cpu = sysconf (_SC_NPROCESSORS_CONF );
3258
3256
3259
3257
if (sched -> map .comp ) {
@@ -3262,16 +3260,15 @@ static int setup_map_cpus(struct perf_sched *sched)
3262
3260
return -1 ;
3263
3261
}
3264
3262
3265
- if (! sched -> map .cpus_str )
3266
- return 0 ;
3267
-
3268
- map = perf_cpu_map__new ( sched -> map .cpus_str );
3269
- if (! map ) {
3270
- pr_err ( "failed to get cpus map from %s\n" , sched -> map . cpus_str ) ;
3271
- return -1 ;
3263
+ if (sched -> map .cpus_str ) {
3264
+ sched -> map . cpus = perf_cpu_map__new ( sched -> map . cpus_str ) ;
3265
+ if (! sched -> map . cpus ) {
3266
+ pr_err ( "failed to get cpus map from %s\n" , sched -> map .cpus_str );
3267
+ zfree ( & sched -> map . comp_cpus );
3268
+ return -1 ;
3269
+ }
3272
3270
}
3273
3271
3274
- sched -> map .cpus = map ;
3275
3272
return 0 ;
3276
3273
}
3277
3274
@@ -3311,20 +3308,34 @@ static int setup_color_cpus(struct perf_sched *sched)
3311
3308
3312
3309
static int perf_sched__map (struct perf_sched * sched )
3313
3310
{
3311
+ int rc = -1 ;
3312
+
3314
3313
if (setup_map_cpus (sched ))
3315
- return -1 ;
3314
+ return rc ;
3316
3315
3317
3316
if (setup_color_pids (sched ))
3318
- return -1 ;
3317
+ goto out_put_map_cpus ;
3319
3318
3320
3319
if (setup_color_cpus (sched ))
3321
- return -1 ;
3320
+ goto out_put_color_pids ;
3322
3321
3323
3322
setup_pager ();
3324
3323
if (perf_sched__read_events (sched ))
3325
- return -1 ;
3324
+ goto out_put_color_cpus ;
3325
+
3326
+ rc = 0 ;
3326
3327
print_bad_events (sched );
3327
- return 0 ;
3328
+
3329
+ out_put_color_cpus :
3330
+ perf_cpu_map__put (sched -> map .color_cpus );
3331
+
3332
+ out_put_color_pids :
3333
+ perf_thread_map__put (sched -> map .color_pids );
3334
+
3335
+ out_put_map_cpus :
3336
+ zfree (& sched -> map .comp_cpus );
3337
+ perf_cpu_map__put (sched -> map .cpus );
3338
+ return rc ;
3328
3339
}
3329
3340
3330
3341
static int perf_sched__replay (struct perf_sched * sched )
0 commit comments