Skip to content

Commit

Permalink
SUNRPC: fix xprt leak on xps allocation failure
Browse files Browse the repository at this point in the history
Callers of rpc_create_xprt expect it to put the xprt on success and
failure.

Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Acked-by: Trond Myklebust <trondmy@primarydata.com>
  • Loading branch information
J. Bruce Fields committed Jun 15, 2016
1 parent eee9301 commit 1208fd5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/sunrpc/clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,10 @@ struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
struct rpc_xprt_switch *xps;

xps = xprt_switch_alloc(xprt, GFP_KERNEL);
if (xps == NULL)
if (xps == NULL) {
xprt_put(xprt);
return ERR_PTR(-ENOMEM);

}
clnt = rpc_new_client(args, xps, xprt, NULL);
if (IS_ERR(clnt))
return clnt;
Expand Down

0 comments on commit 1208fd5

Please sign in to comment.