diff options
author | Ran Xiaokai <[email protected]> | 2021-11-08 18:35:22 -0800 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2021-11-09 10:02:52 -0800 |
commit | ba1f70ddd1809c03660ddcfb757e1c1ced8b676d (patch) | |
tree | 93b3633ae001b74a97a45ba02c5ca37808bd0a78 | |
parent | 10a6de19cad6efb9b49883513afb810dc265fca2 (diff) |
kernel/fork.c: unshare(): use swap() to make code cleaner
Use swap() instead of reimplementing it.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Ran Xiaokai <[email protected]>
Cc: Gabriel Krisman Bertazi <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Eric W. Biederman <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Alexey Gladkov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | kernel/fork.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 38681ad44c76..acf94e660ce3 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -3027,7 +3027,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; @@ -3114,11 +3114,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); |