Skip to content

Commit

Permalink
binfmt_misc: ->s_root is not going anywhere
Browse files Browse the repository at this point in the history
... no need to dget/dput it.

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed May 29, 2016
1 parent 84c60b1 commit ea7d4c0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions fs/binfmt_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,12 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
break;
case 3:
/* Delete this handler. */
root = dget(file->f_path.dentry->d_sb->s_root);
root = file_inode(file)->i_sb->s_root;
inode_lock(d_inode(root));

kill_node(e);

inode_unlock(d_inode(root));
dput(root);
break;
default:
return res;
Expand All @@ -665,16 +664,15 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
{
Node *e;
struct inode *inode;
struct dentry *root, *dentry;
struct super_block *sb = file->f_path.dentry->d_sb;
struct super_block *sb = file_inode(file)->i_sb;
struct dentry *root = sb->s_root, *dentry;
int err = 0;

e = create_entry(buffer, count);

if (IS_ERR(e))
return PTR_ERR(e);

root = dget(sb->s_root);
inode_lock(d_inode(root));
dentry = lookup_one_len(e->name, root, strlen(e->name));
err = PTR_ERR(dentry);
Expand Down Expand Up @@ -712,7 +710,6 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
dput(dentry);
out:
inode_unlock(d_inode(root));
dput(root);

if (err) {
kfree(e);
Expand Down Expand Up @@ -753,14 +750,13 @@ static ssize_t bm_status_write(struct file *file, const char __user *buffer,
break;
case 3:
/* Delete all handlers. */
root = dget(file->f_path.dentry->d_sb->s_root);
root = file_inode(file)->i_sb->s_root;
inode_lock(d_inode(root));

while (!list_empty(&entries))
kill_node(list_entry(entries.next, Node, list));

inode_unlock(d_inode(root));
dput(root);
break;
default:
return res;
Expand Down

0 comments on commit ea7d4c0

Please sign in to comment.