diff --git a/fs/open.c b/fs/open.c index 02dc608d40d8..bc2d1db2fcba 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1441,11 +1441,11 @@ static long do_sys_openat2(int dfd, const char __user *filename, if (IS_ERR(f)) { put_unused_fd(fd); fd = PTR_ERR(f); + putname(tmp); } else { fd_install(fd, f); } } - putname(tmp); return fd; }