Skip to content

Commit 081ed90

Browse files
committed
Merge tag 'pm-6.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fix from Rafael Wysocki: "Fix cpufreq reference counting in the DTPM (dynamic thermal and power management) power capping framework (Lukasz Luba)" * tag 'pm-6.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: powercap: DTPM: Fix missing cpufreq_cpu_put() calls
2 parents c3e2f9b + bdefd99 commit 081ed90

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

drivers/powercap/dtpm_cpu.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ static void pd_release(struct dtpm *dtpm)
140140
if (policy) {
141141
for_each_cpu(dtpm_cpu->cpu, policy->related_cpus)
142142
per_cpu(dtpm_per_cpu, dtpm_cpu->cpu) = NULL;
143+
144+
cpufreq_cpu_put(policy);
143145
}
144146

145147
kfree(dtpm_cpu);
@@ -191,12 +193,16 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent)
191193
return 0;
192194

193195
pd = em_cpu_get(cpu);
194-
if (!pd || em_is_artificial(pd))
195-
return -EINVAL;
196+
if (!pd || em_is_artificial(pd)) {
197+
ret = -EINVAL;
198+
goto release_policy;
199+
}
196200

197201
dtpm_cpu = kzalloc(sizeof(*dtpm_cpu), GFP_KERNEL);
198-
if (!dtpm_cpu)
199-
return -ENOMEM;
202+
if (!dtpm_cpu) {
203+
ret = -ENOMEM;
204+
goto release_policy;
205+
}
200206

201207
dtpm_init(&dtpm_cpu->dtpm, &dtpm_ops);
202208
dtpm_cpu->cpu = cpu;
@@ -216,6 +222,7 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent)
216222
if (ret)
217223
goto out_dtpm_unregister;
218224

225+
cpufreq_cpu_put(policy);
219226
return 0;
220227

221228
out_dtpm_unregister:
@@ -227,6 +234,8 @@ static int __dtpm_cpu_setup(int cpu, struct dtpm *parent)
227234
per_cpu(dtpm_per_cpu, cpu) = NULL;
228235
kfree(dtpm_cpu);
229236

237+
release_policy:
238+
cpufreq_cpu_put(policy);
230239
return ret;
231240
}
232241

0 commit comments

Comments
 (0)