Skip to content

Commit

Permalink
nsproxy: use put_nsproxy() in switch_task_namespaces()
Browse files Browse the repository at this point in the history
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: Hui Su <sh_def@163.com>
[christian.brauner@ubuntu.com: expand commit message]
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/20201115180054.GA371317@rlk
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
liulangrenaaa authored and Christian Brauner committed Nov 19, 2020
1 parent bda4c60 commit aabe19b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/nsproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
* it along with CLONE_NEWIPC.
*/
if ((flags & (CLONE_NEWIPC | CLONE_SYSVSEM)) ==
(CLONE_NEWIPC | CLONE_SYSVSEM))
(CLONE_NEWIPC | CLONE_SYSVSEM))
return -EINVAL;

new_ns = create_new_namespaces(flags, tsk, user_ns, tsk->fs);
Expand Down Expand Up @@ -250,8 +250,8 @@ void switch_task_namespaces(struct task_struct *p, struct nsproxy *new)
p->nsproxy = new;
task_unlock(p);

if (ns && atomic_dec_and_test(&ns->count))
free_nsproxy(ns);
if (ns)
put_nsproxy(ns);
}

void exit_task_namespaces(struct task_struct *p)
Expand Down

0 comments on commit aabe19b

Please sign in to comment.