Skip to content

Commit

Permalink
SUNRPC: Destroy the back channel when we destroy the host transport
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-by: kbuild test robot <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
  • Loading branch information
trondmy authored and amschuma-ntap committed Oct 30, 2019
1 parent 9edb455 commit 669996a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/linux/sunrpc/bc_xprt.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ static inline int xprt_setup_backchannel(struct rpc_xprt *xprt,
return 0;
}

static inline void xprt_destroy_backchannel(struct rpc_xprt *xprt,
unsigned int max_reqs)
{
}

static inline bool svc_is_backchannel(const struct svc_rqst *rqstp)
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion net/sunrpc/backchannel_rqst.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void xprt_destroy_bc(struct rpc_xprt *xprt, unsigned int max_reqs)
goto out;

spin_lock_bh(&xprt->bc_pa_lock);
xprt->bc_alloc_max -= max_reqs;
xprt->bc_alloc_max -= min(max_reqs, xprt->bc_alloc_max);
list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) {
dprintk("RPC: req=%p\n", req);
list_del(&req->rq_bc_pa_list);
Expand Down
5 changes: 5 additions & 0 deletions net/sunrpc/xprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,11 @@ static void xprt_destroy_cb(struct work_struct *work)
rpc_destroy_wait_queue(&xprt->sending);
rpc_destroy_wait_queue(&xprt->backlog);
kfree(xprt->servername);
/*
* Destroy any existing back channel
*/
xprt_destroy_backchannel(xprt, UINT_MAX);

/*
* Tear down transport state and free the rpc_xprt
*/
Expand Down

0 comments on commit 669996a

Please sign in to comment.