未验证 提交 aabe19b8 编写于 作者: liulangrenaaa's avatar liulangrenaaa 提交者: Christian Brauner

nsproxy: use put_nsproxy() in switch_task_namespaces()

We already have a dedicated helper that handles reference count
checking so stop open-coding the reference count check in
switch_task_namespaces() and use the dedicated put_nsproxy() helper
instead.
Take the change to fix a whitespace issue too.
Signed-off-by: liulangrenaaa's avatarHui Su <sh_def@163.com>
[christian.brauner@ubuntu.com: expand commit message]
Acked-by: NChristian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/20201115180054.GA371317@rlkSigned-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
上级 bda4c60d
...@@ -173,7 +173,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) ...@@ -173,7 +173,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
* it along with CLONE_NEWIPC. * it along with CLONE_NEWIPC.
*/ */
if ((flags & (CLONE_NEWIPC | CLONE_SYSVSEM)) == if ((flags & (CLONE_NEWIPC | CLONE_SYSVSEM)) ==
(CLONE_NEWIPC | CLONE_SYSVSEM)) (CLONE_NEWIPC | CLONE_SYSVSEM))
return -EINVAL; return -EINVAL;
new_ns = create_new_namespaces(flags, tsk, user_ns, tsk->fs); new_ns = create_new_namespaces(flags, tsk, user_ns, tsk->fs);
...@@ -250,8 +250,8 @@ void switch_task_namespaces(struct task_struct *p, struct nsproxy *new) ...@@ -250,8 +250,8 @@ void switch_task_namespaces(struct task_struct *p, struct nsproxy *new)
p->nsproxy = new; p->nsproxy = new;
task_unlock(p); task_unlock(p);
if (ns && atomic_dec_and_test(&ns->count)) if (ns)
free_nsproxy(ns); put_nsproxy(ns);
} }
void exit_task_namespaces(struct task_struct *p) void exit_task_namespaces(struct task_struct *p)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册