Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SUNRPC: Destroy the back channel when we destroy the host transport

When we're destroying the host transport mechanism, we should ensure
that we do not leak memory by failing to release any back channel
slots that might still exist.

Reported-by: Neil Brown <neilb@suse.de>
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

authored by

Trond Myklebust and committed by
Anna Schumaker
669996ad 9edb455e

+11 -1
+5
include/linux/sunrpc/bc_xprt.h
··· 64 64 return 0; 65 65 } 66 66 67 + static inline void xprt_destroy_backchannel(struct rpc_xprt *xprt, 68 + unsigned int max_reqs) 69 + { 70 + } 71 + 67 72 static inline bool svc_is_backchannel(const struct svc_rqst *rqstp) 68 73 { 69 74 return false;
+1 -1
net/sunrpc/backchannel_rqst.c
··· 220 220 goto out; 221 221 222 222 spin_lock_bh(&xprt->bc_pa_lock); 223 - xprt->bc_alloc_max -= max_reqs; 223 + xprt->bc_alloc_max -= min(max_reqs, xprt->bc_alloc_max); 224 224 list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) { 225 225 dprintk("RPC: req=%p\n", req); 226 226 list_del(&req->rq_bc_pa_list);
+5
net/sunrpc/xprt.c
··· 1943 1943 rpc_destroy_wait_queue(&xprt->backlog); 1944 1944 kfree(xprt->servername); 1945 1945 /* 1946 + * Destroy any existing back channel 1947 + */ 1948 + xprt_destroy_backchannel(xprt, UINT_MAX); 1949 + 1950 + /* 1946 1951 * Tear down transport state and free the rpc_xprt 1947 1952 */ 1948 1953 xprt->ops->destroy(xprt);