diff options
Diffstat (limited to 'fs/ecryptfs/super.c')
-rw-r--r-- | fs/ecryptfs/super.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c index 18d77f8aa7cd..b97e2106f670 100644 --- a/fs/ecryptfs/super.c +++ b/fs/ecryptfs/super.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/mount.h> | 27 | #include <linux/mount.h> |
28 | #include <linux/key.h> | 28 | #include <linux/key.h> |
29 | #include <linux/seq_file.h> | 29 | #include <linux/seq_file.h> |
30 | #include <linux/file.h> | ||
30 | #include <linux/crypto.h> | 31 | #include <linux/crypto.h> |
31 | #include "ecryptfs_kernel.h" | 32 | #include "ecryptfs_kernel.h" |
32 | 33 | ||
@@ -63,9 +64,10 @@ out: | |||
63 | * ecryptfs_destroy_inode | 64 | * ecryptfs_destroy_inode |
64 | * @inode: The ecryptfs inode | 65 | * @inode: The ecryptfs inode |
65 | * | 66 | * |
66 | * This is used during the final destruction of the inode. | 67 | * This is used during the final destruction of the inode. All |
67 | * All allocation of memory related to the inode, including allocated | 68 | * allocation of memory related to the inode, including allocated |
68 | * memory in the crypt_stat struct, will be released here. | 69 | * memory in the crypt_stat struct, will be released here. This |
70 | * function also fput()'s the persistent file for the lower inode. | ||
69 | * There should be no chance that this deallocation will be missed. | 71 | * There should be no chance that this deallocation will be missed. |
70 | */ | 72 | */ |
71 | static void ecryptfs_destroy_inode(struct inode *inode) | 73 | static void ecryptfs_destroy_inode(struct inode *inode) |
@@ -73,6 +75,20 @@ static void ecryptfs_destroy_inode(struct inode *inode) | |||
73 | struct ecryptfs_inode_info *inode_info; | 75 | struct ecryptfs_inode_info *inode_info; |
74 | 76 | ||
75 | inode_info = ecryptfs_inode_to_private(inode); | 77 | inode_info = ecryptfs_inode_to_private(inode); |
78 | mutex_lock(&inode_info->lower_file_mutex); | ||
79 | if (inode_info->lower_file) { | ||
80 | struct dentry *lower_dentry = | ||
81 | inode_info->lower_file->f_dentry; | ||
82 | |||
83 | BUG_ON(!lower_dentry); | ||
84 | if (lower_dentry->d_inode) { | ||
85 | fput(inode_info->lower_file); | ||
86 | inode_info->lower_file = NULL; | ||
87 | d_drop(lower_dentry); | ||
88 | d_delete(lower_dentry); | ||
89 | } | ||
90 | } | ||
91 | mutex_unlock(&inode_info->lower_file_mutex); | ||
76 | ecryptfs_destroy_crypt_stat(&inode_info->crypt_stat); | 92 | ecryptfs_destroy_crypt_stat(&inode_info->crypt_stat); |
77 | kmem_cache_free(ecryptfs_inode_info_cache, inode_info); | 93 | kmem_cache_free(ecryptfs_inode_info_cache, inode_info); |
78 | } | 94 | } |