]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
close_files(): don't bother with xchg()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 1 Aug 2024 20:03:19 +0000 (16:03 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 7 Oct 2024 17:34:41 +0000 (13:34 -0400)
At that point nobody else has references to the victim files_struct;
as the matter of fact, the caller will free it immediately after
close_files() returns, with no RCU delays or anything of that sort.

That's why we are not protecting against fdtable reallocation on
expansion, not cleaning the bitmaps, etc.  There's no point
zeroing the pointers in ->fd[] either, let alone make that an
atomic operation.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/file.c

index 991860ee7848256cbbd9d521158a38fafd90258c..8770010170c507bb473928a4895d2586e6562223 100644 (file)
--- a/fs/file.c
+++ b/fs/file.c
@@ -413,7 +413,7 @@ static struct fdtable *close_files(struct files_struct * files)
                set = fdt->open_fds[j++];
                while (set) {
                        if (set & 1) {
-                               struct file * file = xchg(&fdt->fd[i], NULL);
+                               struct file *file = fdt->fd[i];
                                if (file) {
                                        filp_close(file, files);
                                        cond_resched();