Skip to content

Commit

Permalink
SUNRPC: Fix a potential memory leak in rpc_new_client
Browse files Browse the repository at this point in the history
If the call to rpciod_up() fails, we currently leak a reference to the
struct rpc_xprt.
As part of the fix, we also remove the redundant check for xprt!=NULL.
This is already taken care of by the callers.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Apr 5, 2013
1 parent 7b1f1fd commit f05c124
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions net/sunrpc/clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
err = rpciod_up();
if (err)
goto out_no_rpciod;
err = -EINVAL;
if (!xprt)
goto out_no_xprt;

err = -EINVAL;
if (args->version >= program->nrvers)
goto out_err;
version = program->version[args->version];
Expand Down Expand Up @@ -382,10 +380,9 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
out_no_stats:
kfree(clnt);
out_err:
xprt_put(xprt);
out_no_xprt:
rpciod_down();
out_no_rpciod:
xprt_put(xprt);
return ERR_PTR(err);
}

Expand Down

0 comments on commit f05c124

Please sign in to comment.