From: Al Viro Date: Thu, 1 Aug 2024 20:03:19 +0000 (-0400) Subject: close_files(): don't bother with xchg() X-Git-Tag: v6.13-rc1~225^2~1^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fa4ffd8e6f6d001da27f00382af79bad0336091;p=thirdparty%2Fkernel%2Flinux.git close_files(): don't bother with xchg() 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 --- diff --git a/fs/file.c b/fs/file.c index 991860ee78482..8770010170c50 100644 --- 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();