Merge tag 'acpi-5.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux-block.git] / kernel / fork.c
index 3f112b11a9ad1453cdfa5f88f8e3d70ac9089213..5de23f3e08bfb3f950c98be428695f35b3e3384d 100644 (file)
@@ -3024,7 +3024,7 @@ int unshare_fd(unsigned long unshare_flags, unsigned int max_fds,
 int ksys_unshare(unsigned long unshare_flags)
 {
        struct fs_struct *fs, *new_fs = NULL;
-       struct files_struct *fd, *new_fd = NULL;
+       struct files_struct *new_fd = NULL;
        struct cred *new_cred = NULL;
        struct nsproxy *new_nsproxy = NULL;
        int do_sysvsem = 0;
@@ -3111,11 +3111,8 @@ int ksys_unshare(unsigned long unshare_flags)
                        spin_unlock(&fs->lock);
                }
 
-               if (new_fd) {
-                       fd = current->files;
-                       current->files = new_fd;
-                       new_fd = fd;
-               }
+               if (new_fd)
+                       swap(current->files, new_fd);
 
                task_unlock(current);