From: Al Viro Date: Wed, 9 Mar 2011 05:17:27 +0000 (-0500) Subject: move may_open() from __open_name_create() to do_last() X-Git-Tag: v3.0~1624^2~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b44f1b3928b6f41532c9a1dc9a6fc665989ad5b;p=platform%2Fkernel%2Flinux-amlogic.git move may_open() from __open_name_create() to do_last() Signed-off-by: Al Viro --- diff --git a/fs/namei.c b/fs/namei.c index 1f561dc..def63e7 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2069,11 +2069,7 @@ out_unlock: 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; } /* @@ -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);