summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>2009-11-25 04:52:12 +0000
committerwollman <wollman@FreeBSD.org>2009-11-25 04:52:12 +0000
commit9d981856ee4aad156fa0d3449733e6a974130e44 (patch)
treed7024c00f5afc055b4356cd8e73ccb4d36c830bb /lib
parentd0aa37ef30706d9707ef8ebd9e7f45542fb22540 (diff)
downloadFreeBSD-src-9d981856ee4aad156fa0d3449733e6a974130e44.zip
FreeBSD-src-9d981856ee4aad156fa0d3449733e6a974130e44.tar.gz
In clnt_raw_create(), avoid minor race condition initializing the
file-scope variable clntraw_private. Found by: Clang static analyzer MFC after: 7 days
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/rpc/clnt_raw.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libc/rpc/clnt_raw.c b/lib/libc/rpc/clnt_raw.c
index 9d34a3d..cd3a384 100644
--- a/lib/libc/rpc/clnt_raw.c
+++ b/lib/libc/rpc/clnt_raw.c
@@ -92,13 +92,13 @@ clnt_raw_create(prog, vers)
rpcprog_t prog;
rpcvers_t vers;
{
- struct clntraw_private *clp = clntraw_private;
+ struct clntraw_private *clp;
struct rpc_msg call_msg;
- XDR *xdrs = &clp->xdr_stream;
- CLIENT *client = &clp->client_object;
+ XDR *xdrs;
+ CLIENT *client;
mutex_lock(&clntraw_lock);
- if (clp == NULL) {
+ if ((clp = clntraw_private) == NULL) {
clp = (struct clntraw_private *)calloc(1, sizeof (*clp));
if (clp == NULL) {
mutex_unlock(&clntraw_lock);
@@ -110,6 +110,9 @@ clnt_raw_create(prog, vers)
clp->_raw_buf = __rpc_rawcombuf;
clntraw_private = clp;
}
+ xdrs = &clp->xdr_stream;
+ client = &clp->client_object;
+
/*
* pre-serialize the static part of the call msg and stash it away
*/
OpenPOWER on IntegriCloud