Hi Eric, Will you be able to merge this patch if it looks o.k.
Parav > -----Original Message----- > From: Parav Pandit [mailto:pa...@mellanox.com] > Sent: Friday, January 27, 2017 1:39 PM > To: ebied...@xmission.com; adityak...@google.com; t...@kernel.org; linux- > ker...@vger.kernel.org > Cc: Parav Pandit <pa...@mellanox.com> > Subject: [PATCH RESEND] nsproxy: Reuse already available put_nsproxy > helper function. > > This patch makes use of already available put_nsproxy() helper function > which already perform atomic check and conditional free. > It also remove braces in put_nsproxy() for single line conditional statement. > Minor fixes for trailing white space, 80 characters etc warnings reported by > checkpatch.pl. > > Resending it to include Eric Biederman to merge the changes. > > Signed-off-by: Parav Pandit <pa...@mellanox.com> > --- > include/linux/nsproxy.h | 10 +++++----- > kernel/nsproxy.c | 12 +++++++----- > 2 files changed, 12 insertions(+), 10 deletions(-) > > diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h index > ac0d65b..24556f4 100644 > --- a/include/linux/nsproxy.h > +++ b/include/linux/nsproxy.h > @@ -33,7 +33,7 @@ struct nsproxy { > struct ipc_namespace *ipc_ns; > struct mnt_namespace *mnt_ns; > struct pid_namespace *pid_ns_for_children; > - struct net *net_ns; > + struct net *net_ns; > struct cgroup_namespace *cgroup_ns; > }; > extern struct nsproxy init_nsproxy; > @@ -68,15 +68,15 @@ struct nsproxy { > void exit_task_namespaces(struct task_struct *tsk); void > switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new); void > free_nsproxy(struct nsproxy *ns); -int > unshare_nsproxy_namespaces(unsigned long, struct nsproxy **, > - struct cred *, struct fs_struct *); > +int unshare_nsproxy_namespaces(unsigned long unshare_flags, > + struct nsproxy **new_nsp, struct cred *new_cred, > + struct fs_struct *new_fs); > int __init nsproxy_cache_init(void); > > static inline void put_nsproxy(struct nsproxy *ns) { > - if (atomic_dec_and_test(&ns->count)) { > + if (atomic_dec_and_test(&ns->count)) > free_nsproxy(ns); > - } > } > > static inline void get_nsproxy(struct nsproxy *ns) diff --git > a/kernel/nsproxy.c b/kernel/nsproxy.c index 782102e..f253655 100644 > --- a/kernel/nsproxy.c > +++ b/kernel/nsproxy.c > @@ -71,7 +71,8 @@ static struct nsproxy > *create_new_namespaces(unsigned long flags, > if (!new_nsp) > return ERR_PTR(-ENOMEM); > > - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, > user_ns, new_fs); > + new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, > user_ns, > + new_fs); > if (IS_ERR(new_nsp->mnt_ns)) { > err = PTR_ERR(new_nsp->mnt_ns); > goto out_ns; > @@ -158,7 +159,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); @@ > -189,7 +190,8 @@ void free_nsproxy(struct nsproxy *ns) > * On success, returns the new nsproxy. > */ > int unshare_nsproxy_namespaces(unsigned long unshare_flags, > - struct nsproxy **new_nsp, struct cred *new_cred, struct fs_struct > *new_fs) > + struct nsproxy **new_nsp, struct cred *new_cred, > + struct fs_struct *new_fs) > { > struct user_namespace *user_ns; > int err = 0; > @@ -224,8 +226,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) > -- > 1.8.3.1