summaryrefslogtreecommitdiff
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 18b9326d951f..f0dae0057ec9 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2204,7 +2204,7 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
umode_t mode;
int error;
int acc_mode;
- struct file *filp;
+ struct file *filp = NULL;
int create_error = 0;
struct dentry *const DENTRY_NOT_SET = (void *) -1UL;
@@ -2271,14 +2271,15 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
od->dentry = DENTRY_NOT_SET;
od->mnt = nd->path.mnt;
- filp = dir->i_op->atomic_open(dir, dentry, od, open_flag, mode,
+ error = dir->i_op->atomic_open(dir, dentry, od, open_flag, mode,
opened);
- if (IS_ERR(filp)) {
+ if (error < 0) {
if (WARN_ON(od->dentry != DENTRY_NOT_SET))
dput(od->dentry);
- if (create_error && PTR_ERR(filp) == -ENOENT)
- filp = ERR_PTR(create_error);
+ if (create_error && error == -ENOENT)
+ error = create_error;
+ filp = ERR_PTR(error);
goto out;
}
@@ -2288,7 +2289,7 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
acc_mode = MAY_OPEN;
}
- if (!filp) {
+ if (error) { /* returned 1, that is */
if (WARN_ON(od->dentry == DENTRY_NOT_SET)) {
filp = ERR_PTR(-EIO);
goto out;
@@ -2304,6 +2305,7 @@ static struct file *atomic_open(struct nameidata *nd, struct dentry *dentry,
* We didn't have the inode before the open, so check open permission
* here.
*/
+ filp = od->filp;
error = may_open(&filp->f_path, acc_mode, open_flag);
if (error) {
fput(filp);