If open fails, don't put the file. This allows it to be reused if open needs to
be retried.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
/* Pick up the filp from the open intent */
filp = nd->intent.open.file;
- nd->intent.open.file = NULL;
/* Has the filesystem initialised the file for us? */
- if (filp->f_path.dentry == NULL) {
+ if (filp->f_path.dentry != NULL) {
+ nd->intent.open.file = NULL;
+ } else {
struct file *res;
path_get(&nd->path);
if (!IS_ERR(res)) {
int error;
+ nd->intent.open.file = NULL;
BUG_ON(res != filp);
error = open_check_o_direct(filp);
filp = ERR_PTR(error);
}
} else {
- put_filp(filp);
+ /* Allow nd->intent.open.file to be recycled */
filp = res;
}
}