diff options
author | Julia Lawall <julia@diku.dk> | 2010-08-06 16:58:49 -0400 |
---|---|---|
committer | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2010-08-09 14:25:24 -0400 |
commit | ceeab92971e8af05c1e81a4ff2c271124b55bb9b (patch) | |
tree | 517cc3160679d39da57cee982a1aff7cbf7fb789 | |
parent | 31f73bee3e170b7cabb35db9e2f4bf7919b9d036 (diff) |
fs/ecryptfs/file.c: introduce missing free
The comments in the code indicate that file_info should be released if the
function fails. This releasing is done at the label out_free, not out.
The semantic match that finds this 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 = kmem_cache_zalloc(...);
...
if (x == NULL) S
<... when != x
when != if (...) { <+...x...+> }
(
x->f1 = E
|
(x->f1 == NULL || ...)
|
f(...,x->f1,...)
)
...>
(
return <+...x...+>;
|
return@p2 ...;
)
@script:python@
p1 << r.p1;
p2 << r.p2;
@@
print "* file: %s kmem_cache_zalloc %s" % (p1[0].file,p1[0].line)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: stable@kernel.org
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
-rw-r--r-- | fs/ecryptfs/file.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 6e4f84cf73e8..622c95140802 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -199,7 +199,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
199 | "the persistent file for the dentry with name " | 199 | "the persistent file for the dentry with name " |
200 | "[%s]; rc = [%d]\n", __func__, | 200 | "[%s]; rc = [%d]\n", __func__, |
201 | ecryptfs_dentry->d_name.name, rc); | 201 | ecryptfs_dentry->d_name.name, rc); |
202 | goto out; | 202 | goto out_free; |
203 | } | 203 | } |
204 | } | 204 | } |
205 | if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY) | 205 | if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY) |
@@ -207,7 +207,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
207 | rc = -EPERM; | 207 | rc = -EPERM; |
208 | printk(KERN_WARNING "%s: Lower persistent file is RO; eCryptfs " | 208 | printk(KERN_WARNING "%s: Lower persistent file is RO; eCryptfs " |
209 | "file must hence be opened RO\n", __func__); | 209 | "file must hence be opened RO\n", __func__); |
210 | goto out; | 210 | goto out_free; |
211 | } | 211 | } |
212 | ecryptfs_set_file_lower( | 212 | ecryptfs_set_file_lower( |
213 | file, ecryptfs_inode_to_private(inode)->lower_file); | 213 | file, ecryptfs_inode_to_private(inode)->lower_file); |