@@ -12109,40 +12109,51 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event)
12109
12109
if (ctx )
12110
12110
perf_event_ctx_unlock (event -> group_leader , ctx );
12111
12111
12112
- if (!ret ) {
12113
- if (!(pmu -> capabilities & PERF_PMU_CAP_EXTENDED_REGS ) &&
12114
- has_extended_regs (event ))
12115
- ret = - EOPNOTSUPP ;
12112
+ if (ret )
12113
+ goto err_pmu ;
12116
12114
12117
- if (pmu -> capabilities & PERF_PMU_CAP_NO_EXCLUDE &&
12118
- event_has_any_exclude_flag (event ))
12119
- ret = - EINVAL ;
12115
+ if (!(pmu -> capabilities & PERF_PMU_CAP_EXTENDED_REGS ) &&
12116
+ has_extended_regs (event )) {
12117
+ ret = - EOPNOTSUPP ;
12118
+ goto err_destroy ;
12119
+ }
12120
12120
12121
- if (pmu -> scope != PERF_PMU_SCOPE_NONE && event -> cpu >= 0 ) {
12122
- const struct cpumask * cpumask = perf_scope_cpu_topology_cpumask (pmu -> scope , event -> cpu );
12123
- struct cpumask * pmu_cpumask = perf_scope_cpumask (pmu -> scope );
12124
- int cpu ;
12125
-
12126
- if (pmu_cpumask && cpumask ) {
12127
- cpu = cpumask_any_and (pmu_cpumask , cpumask );
12128
- if (cpu >= nr_cpu_ids )
12129
- ret = - ENODEV ;
12130
- else
12131
- event -> event_caps |= PERF_EV_CAP_READ_SCOPE ;
12132
- } else {
12133
- ret = - ENODEV ;
12134
- }
12135
- }
12121
+ if (pmu -> capabilities & PERF_PMU_CAP_NO_EXCLUDE &&
12122
+ event_has_any_exclude_flag (event )) {
12123
+ ret = - EINVAL ;
12124
+ goto err_destroy ;
12125
+ }
12136
12126
12137
- if (ret && event -> destroy )
12138
- event -> destroy (event );
12127
+ if (pmu -> scope != PERF_PMU_SCOPE_NONE && event -> cpu >= 0 ) {
12128
+ const struct cpumask * cpumask ;
12129
+ struct cpumask * pmu_cpumask ;
12130
+ int cpu ;
12131
+
12132
+ cpumask = perf_scope_cpu_topology_cpumask (pmu -> scope , event -> cpu );
12133
+ pmu_cpumask = perf_scope_cpumask (pmu -> scope );
12134
+
12135
+ ret = - ENODEV ;
12136
+ if (!pmu_cpumask || !cpumask )
12137
+ goto err_destroy ;
12138
+
12139
+ cpu = cpumask_any_and (pmu_cpumask , cpumask );
12140
+ if (cpu >= nr_cpu_ids )
12141
+ goto err_destroy ;
12142
+
12143
+ event -> event_caps |= PERF_EV_CAP_READ_SCOPE ;
12139
12144
}
12140
12145
12141
- if (ret ) {
12142
- event -> pmu = NULL ;
12143
- module_put (pmu -> module );
12146
+ return 0 ;
12147
+
12148
+ err_destroy :
12149
+ if (event -> destroy ) {
12150
+ event -> destroy (event );
12151
+ event -> destroy = NULL ;
12144
12152
}
12145
12153
12154
+ err_pmu :
12155
+ event -> pmu = NULL ;
12156
+ module_put (pmu -> module );
12146
12157
return ret ;
12147
12158
}
12148
12159
0 commit comments