Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Nov 2006 16:53:43 GMT
From:      Paolo Pisati <piso@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 109130 for review
Message-ID:  <200611031653.kA3GrhHF035922@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=109130

Change 109130 by piso@piso_newluxor on 2006/11/03 16:52:54

	Close a small race: use a stack variable instead of returning
	a reference to a field inside the libalias struct (that is 
	no more protected by the lock).  

Affected files ...

.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_db.c#15 edit

Differences ...

==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_db.c#15 (text+ko) ====

@@ -2613,15 +2613,14 @@
 				 * do a probe for flag values) */
 )
 {
+	int res = -1;
 
 	LIBALIAS_LOCK(la);
 /* Enable logging? */
 	if (flags & mask & PKT_ALIAS_LOG) {
 		/* Do the enable */
-		if (InitPacketAliasLog(la) == ENOMEM) {
-			LIBALIAS_UNLOCK(la);
-			return (-1);
-		}
+		if (InitPacketAliasLog(la) == ENOMEM)
+			goto getout;
 	} else
 /* _Disable_ logging? */
 	if (~flags & mask & PKT_ALIAS_LOG) {
@@ -2640,8 +2639,10 @@
 
 /* Other flags can be set/cleared without special action */
 	la->packetAliasMode = (flags & mask) | (la->packetAliasMode & ~mask);
+	res = la->packetAliasMode;
+getout:
 	LIBALIAS_UNLOCK(la);
-	return (la->packetAliasMode);
+	return (res);
 }
 
 



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