nfsd: call nfsd_last_thread() before final nfsd_put()
authorNeilBrown <neilb@suse.de>
Fri, 15 Dec 2023 00:56:31 +0000 (11:56 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Jan 2024 12:42:42 +0000 (12:42 +0000)
commitc21acd6731680a9af0bddd78f0920bda3af616bb
treed6cf2c720443e6f10ff0594b1b3c643331e25e1d
parent7b5ef500d8b38961f449582e61c2aad4bb22f4f2
nfsd: call nfsd_last_thread() before final nfsd_put()

commit 2a501f55cd641eb4d3c16a2eab0d678693fac663 upstream.

If write_ports_addfd or write_ports_addxprt fail, they call nfsd_put()
without calling nfsd_last_thread().  This leaves nn->nfsd_serv pointing
to a structure that has been freed.

So remove 'static' from nfsd_last_thread() and call it when the
nfsd_serv is about to be destroyed.

Fixes: ec52361df99b ("SUNRPC: stop using ->sv_nrthreads as a refcount")
Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfsd/nfsctl.c
fs/nfsd/nfsd.h
fs/nfsd/nfssvc.c