* [PATCH] drivers/cpufreq: Add calls to cpufreq_cpu_put
@ 2008-01-06 16:05 Julia Lawall
0 siblings, 0 replies; only message in thread
From: Julia Lawall @ 2008-01-06 16:05 UTC (permalink / raw)
To: davej, cpufreq, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
A call to cpufreq_cpu_get should be matched by a call to cpufreq_cpu_put.
The problem was fixed using the following semantic patch.
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
type T;
identifier E;
expression E1, E2;
int ret;
statement S;
@@
T E;
... when any
(
E = cpufreq_cpu_get(...);
if (E == NULL) S
|
if ((E = cpufreq_cpu_get(...)) == NULL) S
)
... when != E2 = E
when strict
(
cpufreq_cpu_put(E);
|
E1 = E;
|
+ cpufreq_cpu_put(E);
return;
|
+ cpufreq_cpu_put(E);
return ret;
)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
diff -u -p a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
--- a/drivers/cpufreq/cpufreq.c 2008-01-06 11:51:40.000000000 +0100
+++ b/drivers/cpufreq/cpufreq.c 2008-01-06 12:01:47.000000000 +0100
@@ -649,8 +649,10 @@ static ssize_t show(struct kobject * kob
if (!policy)
return -EINVAL;
- if (lock_policy_rwsem_read(policy->cpu) < 0)
+ if (lock_policy_rwsem_read(policy->cpu) < 0) {
+ cpufreq_cpu_put(policy);
return -EINVAL;
+ }
if (fattr->show)
ret = fattr->show(policy, buf);
@@ -673,8 +675,10 @@ static ssize_t store(struct kobject * ko
if (!policy)
return -EINVAL;
- if (lock_policy_rwsem_write(policy->cpu) < 0)
+ if (lock_policy_rwsem_write(policy->cpu) < 0) {
+ cpufreq_cpu_put(policy);
return -EINVAL;
+ }
if (fattr->store)
ret = fattr->store(policy, buf, count);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-01-06 16:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-06 16:05 [PATCH] drivers/cpufreq: Add calls to cpufreq_cpu_put Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).