Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Nov 2009 04:52:12 +0000 (UTC)
From:      Garrett Wollman <wollman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r199786 - head/lib/libc/rpc
Message-ID:  <200911250452.nAP4qCvE039716@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
 	 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911250452.nAP4qCvE039716>