diff options
author | Julia Lawall <julia@diku.dk> | 2010-06-01 10:35:15 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-06-02 05:08:42 -0400 |
commit | dfe5c7b7e710d8ed885068b0fcfa6f66ab685592 (patch) | |
tree | b0d9a1529d8d1be97419f11b1071c67927dff69b | |
parent | 33ccbc320fc38094128c68b2ee0b305884965bd4 (diff) |
HID: roccat: introduce missing kfree
Error handling code following a kmalloc should free the allocated data.
The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,f1,l;
position p1,p2;
expression *ptr != NULL;
@@
x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
when != if (...) { <+...x...+> }
(
x->f1 = E
|
(x->f1 == NULL || ...)
|
f(...,x->f1,...)
)
...>
(
return \(0\|<+...x...+>\|ptr\);
|
return@p2 ...;
)
@script:python@
p1 << r.p1;
p2 << r.p2;
@@
print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/hid-roccat.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c index e05d48edb66..f6e80c7ca61 100644 --- a/drivers/hid/hid-roccat.c +++ b/drivers/hid/hid-roccat.c | |||
@@ -168,7 +168,7 @@ static int roccat_open(struct inode *inode, struct file *file) | |||
168 | printk(KERN_EMERG "roccat device with minor %d doesn't exist\n", | 168 | printk(KERN_EMERG "roccat device with minor %d doesn't exist\n", |
169 | minor); | 169 | minor); |
170 | error = -ENODEV; | 170 | error = -ENODEV; |
171 | goto exit_unlock; | 171 | goto exit_err; |
172 | } | 172 | } |
173 | 173 | ||
174 | if (!device->open++) { | 174 | if (!device->open++) { |
@@ -178,7 +178,7 @@ static int roccat_open(struct inode *inode, struct file *file) | |||
178 | PM_HINT_FULLON); | 178 | PM_HINT_FULLON); |
179 | if (error < 0) { | 179 | if (error < 0) { |
180 | --device->open; | 180 | --device->open; |
181 | goto exit_unlock; | 181 | goto exit_err; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | error = device->hid->ll_driver->open(device->hid); | 184 | error = device->hid->ll_driver->open(device->hid); |
@@ -187,7 +187,7 @@ static int roccat_open(struct inode *inode, struct file *file) | |||
187 | device->hid->ll_driver->power(device->hid, | 187 | device->hid->ll_driver->power(device->hid, |
188 | PM_HINT_NORMAL); | 188 | PM_HINT_NORMAL); |
189 | --device->open; | 189 | --device->open; |
190 | goto exit_unlock; | 190 | goto exit_err; |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
@@ -202,6 +202,9 @@ exit_unlock: | |||
202 | mutex_unlock(&device->readers_lock); | 202 | mutex_unlock(&device->readers_lock); |
203 | mutex_unlock(&devices_lock); | 203 | mutex_unlock(&devices_lock); |
204 | return error; | 204 | return error; |
205 | exit_err: | ||
206 | kfree(reader); | ||
207 | goto exit_unlock; | ||
205 | } | 208 | } |
206 | 209 | ||
207 | static int roccat_release(struct inode *inode, struct file *file) | 210 | static int roccat_release(struct inode *inode, struct file *file) |