Return-Path: Received: from fldsmtpe03.verizon.com ([140.108.26.142]:37664 "EHLO fldsmtpe03.verizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932948AbdJKArS (ORCPT ); Tue, 10 Oct 2017 20:47:18 -0400 From: "Levin, Alexander (Sasha Levin)" To: "gregkh@linuxfoundation.org" CC: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [GIT PULL for-4.4 24/25] nfsd/callback: Cleanup callback cred on shutdown Date: Wed, 11 Oct 2017 00:45:44 +0000 Message-ID: <20171011004533.8044-25-alexander.levin@verizon.com> References: <20171011004533.8044-1-alexander.levin@verizon.com> In-Reply-To: <20171011004533.8044-1-alexander.levin@verizon.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Kinglong Mee [ Upstream commit f7d1ddbe7648af7460d23688c8c131342eb43b3a ] The rpccred gotten from rpc_lookup_machine_cred() should be put when state is shutdown. Signed-off-by: Kinglong Mee Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin --- fs/nfsd/nfs4callback.c | 8 ++++++++ fs/nfsd/nfs4state.c | 10 ++++++---- fs/nfsd/state.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 15bdc2d48cfe..24ace275160c 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -696,6 +696,14 @@ int set_callback_cred(void) return 0; } =20 +void cleanup_callback_cred(void) +{ + if (callback_cred) { + put_rpccred(callback_cred); + callback_cred =3D NULL; + } +} + static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, stru= ct rpc_clnt *client, struct nfsd4_session *ses) { if (clp->cl_minorversion =3D=3D 0) { diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 9e5a6842346e..ca9ebc3242d3 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6792,23 +6792,24 @@ nfs4_state_start(void) =20 ret =3D set_callback_cred(); if (ret) - return -ENOMEM; + return ret; + laundry_wq =3D alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd4"); if (laundry_wq =3D=3D NULL) { ret =3D -ENOMEM; - goto out_recovery; + goto out_cleanup_cred; } ret =3D nfsd4_create_callback_queue(); if (ret) goto out_free_laundry; =20 set_max_delegations(); - return 0; =20 out_free_laundry: destroy_workqueue(laundry_wq); -out_recovery: +out_cleanup_cred: + cleanup_callback_cred(); return ret; } =20 @@ -6847,6 +6848,7 @@ nfs4_state_shutdown(void) { destroy_workqueue(laundry_wq); nfsd4_destroy_callback_queue(); + cleanup_callback_cred(); } =20 static void diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 5134eedcb16c..86af697c21d3 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -595,6 +595,7 @@ extern struct nfs4_client_reclaim *nfsd4_find_reclaim_c= lient(const char *recdir, extern __be32 nfs4_check_open_reclaim(clientid_t *clid, struct nfsd4_compound_state *cstate, struct nfsd_net *nn); extern int set_callback_cred(void); +extern void cleanup_callback_cred(void); extern void nfsd4_probe_callback(struct nfs4_client *clp); extern void nfsd4_probe_callback_sync(struct nfs4_client *clp); extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_= conn *); --=20 2.11.0