lift fput() on late failures into path_openat()

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2018-06-08 12:56:55 -04:00
Родитель 4d27f3266f
Коммит 7c1c01ec20
1 изменённых файлов: 12 добавлений и 16 удалений

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

@ -3407,8 +3407,6 @@ opened:
if (!error && will_truncate) if (!error && will_truncate)
error = handle_truncate(file); error = handle_truncate(file);
out: out:
if (unlikely(error) && (*opened & FILE_OPENED))
fput(file);
if (unlikely(error > 0)) { if (unlikely(error > 0)) {
WARN_ON(1); WARN_ON(1);
error = -EINVAL; error = -EINVAL;
@ -3484,8 +3482,6 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
if (error) if (error)
goto out2; goto out2;
error = open_check_o_direct(file); error = open_check_o_direct(file);
if (error)
fput(file);
out2: out2:
mnt_drop_write(path.mnt); mnt_drop_write(path.mnt);
out: out:
@ -3545,20 +3541,20 @@ static struct file *path_openat(struct nameidata *nd,
} }
terminate_walk(nd); terminate_walk(nd);
out2: out2:
if (!(opened & FILE_OPENED)) { if (likely(!error)) {
BUG_ON(!error); if (likely(opened & FILE_OPENED))
fput(file); return file;
WARN_ON(1);
error = -EINVAL;
} }
if (unlikely(error)) { fput(file);
if (error == -EOPENSTALE) { if (error == -EOPENSTALE) {
if (flags & LOOKUP_RCU) if (flags & LOOKUP_RCU)
error = -ECHILD; error = -ECHILD;
else else
error = -ESTALE; error = -ESTALE;
}
file = ERR_PTR(error);
} }
return file; return ERR_PTR(error);
} }
struct file *do_filp_open(int dfd, struct filename *pathname, struct file *do_filp_open(int dfd, struct filename *pathname,