Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f05c124a authored by Trond Myklebust's avatar Trond Myklebust
Browse files

SUNRPC: Fix a potential memory leak in rpc_new_client



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: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 7b1f1fd1
Loading
Loading
Loading
Loading
+2 −5
Original line number Original line Diff line number Diff line
@@ -304,10 +304,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
	err = rpciod_up();
	err = rpciod_up();
	if (err)
	if (err)
		goto out_no_rpciod;
		goto out_no_rpciod;
	err = -EINVAL;
	if (!xprt)
		goto out_no_xprt;


	err = -EINVAL;
	if (args->version >= program->nrvers)
	if (args->version >= program->nrvers)
		goto out_err;
		goto out_err;
	version = program->version[args->version];
	version = program->version[args->version];
@@ -382,10 +380,9 @@ out_no_principal:
out_no_stats:
out_no_stats:
	kfree(clnt);
	kfree(clnt);
out_err:
out_err:
	xprt_put(xprt);
out_no_xprt:
	rpciod_down();
	rpciod_down();
out_no_rpciod:
out_no_rpciod:
	xprt_put(xprt);
	return ERR_PTR(err);
	return ERR_PTR(err);
}
}