[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>
This commit is contained in:
Ulrich Drepper 2006-02-04 23:28:02 -08:00 коммит произвёл Linus Torvalds
Родитель f55eab822b
Коммит 170aa3d026
1 изменённых файлов: 16 добавлений и 16 удалений

Просмотреть файл

@ -1070,6 +1070,8 @@ static int fastcall do_path_lookup(int dfd, const char *name,
unsigned int flags, struct nameidata *nd) unsigned int flags, struct nameidata *nd)
{ {
int retval = 0; int retval = 0;
int fput_needed;
struct file *file;
nd->last_type = LAST_ROOT; /* if there are only slashes... */ nd->last_type = LAST_ROOT; /* if there are only slashes... */
nd->flags = flags; nd->flags = flags;
@ -1091,29 +1093,22 @@ static int fastcall do_path_lookup(int dfd, const char *name,
nd->mnt = mntget(current->fs->pwdmnt); nd->mnt = mntget(current->fs->pwdmnt);
nd->dentry = dget(current->fs->pwd); nd->dentry = dget(current->fs->pwd);
} else { } else {
struct file *file;
int fput_needed;
struct dentry *dentry; struct dentry *dentry;
file = fget_light(dfd, &fput_needed); file = fget_light(dfd, &fput_needed);
if (!file) { retval = -EBADF;
retval = -EBADF; if (!file)
goto out_fail; goto unlock_fail;
}
dentry = file->f_dentry; dentry = file->f_dentry;
if (!S_ISDIR(dentry->d_inode->i_mode)) { retval = -ENOTDIR;
retval = -ENOTDIR; if (!S_ISDIR(dentry->d_inode->i_mode))
fput_light(file, fput_needed); goto fput_unlock_fail;
goto out_fail;
}
retval = file_permission(file, MAY_EXEC); retval = file_permission(file, MAY_EXEC);
if (retval) { if (retval)
fput_light(file, fput_needed); goto fput_unlock_fail;
goto out_fail;
}
nd->mnt = mntget(file->f_vfsmnt); nd->mnt = mntget(file->f_vfsmnt);
nd->dentry = dget(dentry); nd->dentry = dget(dentry);
@ -1127,7 +1122,12 @@ out:
if (unlikely(current->audit_context if (unlikely(current->audit_context
&& nd && nd->dentry && nd->dentry->d_inode)) && nd && nd->dentry && nd->dentry->d_inode))
audit_inode(name, nd->dentry->d_inode, flags); audit_inode(name, nd->dentry->d_inode, flags);
out_fail: return retval;
fput_unlock_fail:
fput_light(file, fput_needed);
unlock_fail:
read_unlock(&current->fs->lock);
return retval; return retval;
} }