diff options
| -rw-r--r-- | fs/debugfs/inode.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 61e9a6815a19..1219dff8e18f 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
| @@ -256,15 +256,17 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) | |||
| 256 | return dentry; | 256 | return dentry; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | static struct dentry *end_creating(struct dentry *dentry, int error) | 259 | static struct dentry *failed_creating(struct dentry *dentry) |
| 260 | { | 260 | { |
| 261 | mutex_unlock(&dentry->d_parent->d_inode->i_mutex); | 261 | mutex_unlock(&dentry->d_parent->d_inode->i_mutex); |
| 262 | dput(dentry); | 262 | dput(dentry); |
| 263 | simple_release_fs(&debugfs_mount, &debugfs_mount_count); | ||
| 264 | return NULL; | ||
| 265 | } | ||
| 263 | 266 | ||
| 264 | if (error) { | 267 | static struct dentry *end_creating(struct dentry *dentry) |
| 265 | dentry = NULL; | 268 | { |
| 266 | simple_release_fs(&debugfs_mount, &debugfs_mount_count); | 269 | mutex_unlock(&dentry->d_parent->d_inode->i_mutex); |
| 267 | } | ||
| 268 | return dentry; | 270 | return dentry; |
| 269 | } | 271 | } |
| 270 | 272 | ||
| @@ -311,15 +313,14 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode, | |||
| 311 | 313 | ||
| 312 | inode = debugfs_get_inode(dentry->d_sb); | 314 | inode = debugfs_get_inode(dentry->d_sb); |
| 313 | if (unlikely(!inode)) | 315 | if (unlikely(!inode)) |
| 314 | return end_creating(dentry, -ENOMEM); | 316 | return failed_creating(dentry); |
| 315 | 317 | ||
| 316 | inode->i_mode = mode; | 318 | inode->i_mode = mode; |
| 317 | inode->i_fop = fops ? fops : &debugfs_file_operations; | 319 | inode->i_fop = fops ? fops : &debugfs_file_operations; |
| 318 | inode->i_private = data; | 320 | inode->i_private = data; |
| 319 | d_instantiate(dentry, inode); | 321 | d_instantiate(dentry, inode); |
| 320 | dget(dentry); | ||
| 321 | fsnotify_create(dentry->d_parent->d_inode, dentry); | 322 | fsnotify_create(dentry->d_parent->d_inode, dentry); |
| 322 | return end_creating(dentry, 0); | 323 | return end_creating(dentry); |
| 323 | } | 324 | } |
| 324 | EXPORT_SYMBOL_GPL(debugfs_create_file); | 325 | EXPORT_SYMBOL_GPL(debugfs_create_file); |
| 325 | 326 | ||
| @@ -351,7 +352,7 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) | |||
| 351 | 352 | ||
| 352 | inode = debugfs_get_inode(dentry->d_sb); | 353 | inode = debugfs_get_inode(dentry->d_sb); |
| 353 | if (unlikely(!inode)) | 354 | if (unlikely(!inode)) |
| 354 | return end_creating(dentry, -ENOMEM); | 355 | return failed_creating(dentry); |
| 355 | 356 | ||
| 356 | inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; | 357 | inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; |
| 357 | inode->i_op = &simple_dir_inode_operations; | 358 | inode->i_op = &simple_dir_inode_operations; |
| @@ -360,10 +361,9 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) | |||
| 360 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 361 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
| 361 | inc_nlink(inode); | 362 | inc_nlink(inode); |
| 362 | d_instantiate(dentry, inode); | 363 | d_instantiate(dentry, inode); |
| 363 | dget(dentry); | ||
| 364 | inc_nlink(dentry->d_parent->d_inode); | 364 | inc_nlink(dentry->d_parent->d_inode); |
| 365 | fsnotify_mkdir(dentry->d_parent->d_inode, dentry); | 365 | fsnotify_mkdir(dentry->d_parent->d_inode, dentry); |
| 366 | return end_creating(dentry, 0); | 366 | return end_creating(dentry); |
| 367 | } | 367 | } |
| 368 | EXPORT_SYMBOL_GPL(debugfs_create_dir); | 368 | EXPORT_SYMBOL_GPL(debugfs_create_dir); |
| 369 | 369 | ||
| @@ -408,14 +408,13 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, | |||
| 408 | inode = debugfs_get_inode(dentry->d_sb); | 408 | inode = debugfs_get_inode(dentry->d_sb); |
| 409 | if (unlikely(!inode)) { | 409 | if (unlikely(!inode)) { |
| 410 | kfree(link); | 410 | kfree(link); |
| 411 | return end_creating(dentry, -ENOMEM); | 411 | return failed_creating(dentry); |
| 412 | } | 412 | } |
| 413 | inode->i_mode = S_IFLNK | S_IRWXUGO; | 413 | inode->i_mode = S_IFLNK | S_IRWXUGO; |
| 414 | inode->i_op = &debugfs_link_operations; | 414 | inode->i_op = &debugfs_link_operations; |
| 415 | inode->i_private = link; | 415 | inode->i_private = link; |
| 416 | d_instantiate(dentry, inode); | 416 | d_instantiate(dentry, inode); |
| 417 | dget(dentry); | 417 | return end_creating(dentry); |
| 418 | return end_creating(dentry, 0); | ||
| 419 | } | 418 | } |
| 420 | EXPORT_SYMBOL_GPL(debugfs_create_symlink); | 419 | EXPORT_SYMBOL_GPL(debugfs_create_symlink); |
| 421 | 420 | ||
