aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-02-05 02:28:02 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-05 14:06:53 -0500
commit170aa3d02614ae621d54af10555e2f48977ae8de (patch)
treec1a93a5c95ccc2225639a7c878f6c16b7c317924 /fs/namei.c
parentf55eab822b93864ef4eef3bd7eadac2a727c914b (diff)
[PATCH] namei.c: unlock missing in error case
Signed-off-by: Ulrich Drepper <drepper@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/namei.c b/fs/namei.c
index b760e1e18b48..faf61c35308c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1070,6 +1070,8 @@ static int fastcall do_path_lookup(int dfd, const char *name,
1070 unsigned int flags, struct nameidata *nd) 1070 unsigned int flags, struct nameidata *nd)
1071{ 1071{
1072 int retval = 0; 1072 int retval = 0;
1073 int fput_needed;
1074 struct file *file;
1073 1075
1074 nd->last_type = LAST_ROOT; /* if there are only slashes... */ 1076 nd->last_type = LAST_ROOT; /* if there are only slashes... */
1075 nd->flags = flags; 1077 nd->flags = flags;
@@ -1091,29 +1093,22 @@ static int fastcall do_path_lookup(int dfd, const char *name,
1091 nd->mnt = mntget(current->fs->pwdmnt); 1093 nd->mnt = mntget(current->fs->pwdmnt);
1092 nd->dentry = dget(current->fs->pwd); 1094 nd->dentry = dget(current->fs->pwd);
1093 } else { 1095 } else {
1094 struct file *file;
1095 int fput_needed;
1096 struct dentry *dentry; 1096 struct dentry *dentry;
1097 1097
1098 file = fget_light(dfd, &fput_needed); 1098 file = fget_light(dfd, &fput_needed);
1099 if (!file) { 1099 retval = -EBADF;
1100 retval = -EBADF; 1100 if (!file)
1101 goto out_fail; 1101 goto unlock_fail;
1102 }
1103 1102
1104 dentry = file->f_dentry; 1103 dentry = file->f_dentry;
1105 1104
1106 if (!S_ISDIR(dentry->d_inode->i_mode)) { 1105 retval = -ENOTDIR;
1107 retval = -ENOTDIR; 1106 if (!S_ISDIR(dentry->d_inode->i_mode))
1108 fput_light(file, fput_needed); 1107 goto fput_unlock_fail;
1109 goto out_fail;
1110 }
1111 1108
1112 retval = file_permission(file, MAY_EXEC); 1109 retval = file_permission(file, MAY_EXEC);
1113 if (retval) { 1110 if (retval)
1114 fput_light(file, fput_needed); 1111 goto fput_unlock_fail;
1115 goto out_fail;
1116 }
1117 1112
1118 nd->mnt = mntget(file->f_vfsmnt); 1113 nd->mnt = mntget(file->f_vfsmnt);
1119 nd->dentry = dget(dentry); 1114 nd->dentry = dget(dentry);
@@ -1127,7 +1122,12 @@ out:
1127 if (unlikely(current->audit_context 1122 if (unlikely(current->audit_context
1128 && nd && nd->dentry && nd->dentry->d_inode)) 1123 && nd && nd->dentry && nd->dentry->d_inode))
1129 audit_inode(name, nd->dentry->d_inode, flags); 1124 audit_inode(name, nd->dentry->d_inode, flags);
1130out_fail: 1125 return retval;
1126
1127fput_unlock_fail:
1128 fput_light(file, fput_needed);
1129unlock_fail:
1130 read_unlock(&current->fs->lock);
1131 return retval; 1131 return retval;
1132} 1132}
1133 1133