svn commit: r199786 - head/lib/libc/rpc
Garrett Wollman
wollman at FreeBSD.org
Wed Nov 25 04:52:13 UTC 2009
Author: wollman
Date: Wed Nov 25 04:52:12 2009
New Revision: 199786
URL: http://svn.freebsd.org/changeset/base/199786
Log:
In clnt_raw_create(), avoid minor race condition initializing the
file-scope variable clntraw_private.
Found by: Clang static analyzer
MFC after: 7 days
Modified:
head/lib/libc/rpc/clnt_raw.c
Modified: head/lib/libc/rpc/clnt_raw.c
==============================================================================
--- head/lib/libc/rpc/clnt_raw.c Wed Nov 25 04:49:41 2009 (r199785)
+++ head/lib/libc/rpc/clnt_raw.c Wed Nov 25 04:52:12 2009 (r199786)
@@ -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
*/
More information about the svn-src-all
mailing list