Skip to content

Commit

Permalink
move may_open() from __open_name_create() to do_last()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Mar 14, 2011
1 parent 0f9d1a1 commit 9b44f1b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -2069,11 +2069,7 @@ static int __open_namei_create(struct nameidata *nd, struct path *path,
mutex_unlock(&dir->d_inode->i_mutex);
dput(nd->path.dentry);
nd->path.dentry = path->dentry;

if (error)
return error;
/* Don't check for write permission, don't truncate */
return may_open(&nd->path, 0, open_flag & ~O_TRUNC);
return error;
}

/*
Expand Down Expand Up @@ -2239,6 +2235,12 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
mnt_drop_write(nd->path.mnt);
goto exit;
}
/* Don't check for write permission, don't truncate */
error = may_open(&nd->path, 0, op->open_flag & ~O_TRUNC);
if (error) {
mnt_drop_write(nd->path.mnt);
goto exit;
}
filp = nameidata_to_filp(nd);
mnt_drop_write(nd->path.mnt);
path_put(&nd->path);
Expand Down

0 comments on commit 9b44f1b

Please sign in to comment.