diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-14 20:41:04 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-22 23:31:32 -0500 |
commit | 1afc99beaf0fca3767d9b67789a7ae91c4f7a9c9 (patch) | |
tree | 9aba84bc2d8e4873859bd81ddf1002fe0e3f9376 /fs/open.c | |
parent | 496ad9aa8ef448058e36ca7a787c61f2e63f0f54 (diff) | |
download | lwn-1afc99beaf0fca3767d9b67789a7ae91c4f7a9c9.tar.gz lwn-1afc99beaf0fca3767d9b67789a7ae91c4f7a9c9.zip |
propagate error from get_empty_filp() to its callers
Based on parts from Anatol's patch (the rest is the next commit).
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/fs/open.c b/fs/open.c index e08643feb574..97a237f67b72 100644 --- a/fs/open.c +++ b/fs/open.c @@ -810,23 +810,22 @@ struct file *dentry_open(const struct path *path, int flags, /* We must always pass in a valid mount pointer. */ BUG_ON(!path->mnt); - error = -ENFILE; f = get_empty_filp(); - if (f == NULL) - return ERR_PTR(error); - - f->f_flags = flags; - f->f_path = *path; - error = do_dentry_open(f, NULL, cred); - if (!error) { - error = open_check_o_direct(f); - if (error) { - fput(f); + if (!IS_ERR(f)) { + f->f_flags = flags; + f->f_path = *path; + error = do_dentry_open(f, NULL, cred); + if (!error) { + /* from now on we need fput() to dispose of f */ + error = open_check_o_direct(f); + if (error) { + fput(f); + f = ERR_PTR(error); + } + } else { + put_filp(f); f = ERR_PTR(error); } - } else { - put_filp(f); - f = ERR_PTR(error); } return f; } |