diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-01-28 14:42:42 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-22 23:31:38 -0500 |
commit | 3f3834c35466324e3a7d7bf3a950dbcd99645f38 (patch) | |
tree | 7ce8af76f87049b672d4625a13317bb8ba3470d9 /drivers/oprofile/oprofilefs.c | |
parent | 2248b87ec1d9f59001d8c69513b2892ac04a2a3d (diff) |
oprofilefs: add missing ->i_mutex locking in object creation
Right now it's safe only during initial mount *and* functions are asking
to be abused for dynamic adding of objects.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/oprofile/oprofilefs.c')
-rw-r--r-- | drivers/oprofile/oprofilefs.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 849357c1045c..445ffda715ad 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c | |||
@@ -139,17 +139,22 @@ static int __oprofilefs_create_file(struct super_block *sb, | |||
139 | struct dentry *dentry; | 139 | struct dentry *dentry; |
140 | struct inode *inode; | 140 | struct inode *inode; |
141 | 141 | ||
142 | mutex_lock(&root->d_inode->i_mutex); | ||
142 | dentry = d_alloc_name(root, name); | 143 | dentry = d_alloc_name(root, name); |
143 | if (!dentry) | 144 | if (!dentry) { |
145 | mutex_unlock(&root->d_inode->i_mutex); | ||
144 | return -ENOMEM; | 146 | return -ENOMEM; |
147 | } | ||
145 | inode = oprofilefs_get_inode(sb, S_IFREG | perm); | 148 | inode = oprofilefs_get_inode(sb, S_IFREG | perm); |
146 | if (!inode) { | 149 | if (!inode) { |
147 | dput(dentry); | 150 | dput(dentry); |
151 | mutex_unlock(&root->d_inode->i_mutex); | ||
148 | return -ENOMEM; | 152 | return -ENOMEM; |
149 | } | 153 | } |
150 | inode->i_fop = fops; | 154 | inode->i_fop = fops; |
155 | inode->i_private = priv; | ||
151 | d_add(dentry, inode); | 156 | d_add(dentry, inode); |
152 | dentry->d_inode->i_private = priv; | 157 | mutex_unlock(&root->d_inode->i_mutex); |
153 | return 0; | 158 | return 0; |
154 | } | 159 | } |
155 | 160 | ||
@@ -212,17 +217,22 @@ struct dentry *oprofilefs_mkdir(struct super_block *sb, | |||
212 | struct dentry *dentry; | 217 | struct dentry *dentry; |
213 | struct inode *inode; | 218 | struct inode *inode; |
214 | 219 | ||
220 | mutex_lock(&root->d_inode->i_mutex); | ||
215 | dentry = d_alloc_name(root, name); | 221 | dentry = d_alloc_name(root, name); |
216 | if (!dentry) | 222 | if (!dentry) { |
223 | mutex_unlock(&root->d_inode->i_mutex); | ||
217 | return NULL; | 224 | return NULL; |
225 | } | ||
218 | inode = oprofilefs_get_inode(sb, S_IFDIR | 0755); | 226 | inode = oprofilefs_get_inode(sb, S_IFDIR | 0755); |
219 | if (!inode) { | 227 | if (!inode) { |
220 | dput(dentry); | 228 | dput(dentry); |
229 | mutex_unlock(&root->d_inode->i_mutex); | ||
221 | return NULL; | 230 | return NULL; |
222 | } | 231 | } |
223 | inode->i_op = &simple_dir_inode_operations; | 232 | inode->i_op = &simple_dir_inode_operations; |
224 | inode->i_fop = &simple_dir_operations; | 233 | inode->i_fop = &simple_dir_operations; |
225 | d_add(dentry, inode); | 234 | d_add(dentry, inode); |
235 | mutex_unlock(&root->d_inode->i_mutex); | ||
226 | return dentry; | 236 | return dentry; |
227 | } | 237 | } |
228 | 238 | ||