Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 May 2016 08:48:33 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300836 - head/sys/rpc
Message-ID:  <201605270848.u4R8mXH7078903@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Fri May 27 08:48:33 2016
New Revision: 300836
URL: https://svnweb.freebsd.org/changeset/base/300836

Log:
  Quell false positives in svc_vc_create and svc_vc_create_conn with cd and xprt
  
  Both cd and xprt will be non-NULL after their respective malloc(9) wrappers are
  called (mem_alloc and svc_xprt_alloc, which calls mem_alloc) as mem_alloc
  always gets called with M_WAITOK|M_ZERO today. Thus, testing for them being
  non-NULL is incorrect -- it misleads Coverity and it misleads the reader.
  
  Remove some unnecessary NULL initializations as a follow up to help solidify
  the fact that these pointers will be initialized properly in sys/rpc/.. with
  the interfaces the way they are currently.
  
  Differential Revision: https://reviews.freebsd.org/D6572
  MFC after: 2 weeks
  Reported by: Coverity
  CID: 1007338, 1007339, 1007340
  Reviewed by: markj, truckman
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/rpc/svc_vc.c

Modified: head/sys/rpc/svc_vc.c
==============================================================================
--- head/sys/rpc/svc_vc.c	Fri May 27 07:33:49 2016	(r300835)
+++ head/sys/rpc/svc_vc.c	Fri May 27 08:48:33 2016	(r300836)
@@ -143,7 +143,7 @@ SVCXPRT *
 svc_vc_create(SVCPOOL *pool, struct socket *so, size_t sendsize,
     size_t recvsize)
 {
-	SVCXPRT *xprt = NULL;
+	SVCXPRT *xprt;
 	struct sockaddr* sa;
 	int error;
 
@@ -189,11 +189,11 @@ svc_vc_create(SVCPOOL *pool, struct sock
 	SOCKBUF_UNLOCK(&so->so_rcv);
 
 	return (xprt);
+
 cleanup_svc_vc_create:
-	if (xprt) {
-		sx_destroy(&xprt->xp_lock);
-		svc_xprt_free(xprt);
-	}
+	sx_destroy(&xprt->xp_lock);
+	svc_xprt_free(xprt);
+
 	return (NULL);
 }
 
@@ -203,8 +203,8 @@ cleanup_svc_vc_create:
 SVCXPRT *
 svc_vc_create_conn(SVCPOOL *pool, struct socket *so, struct sockaddr *raddr)
 {
-	SVCXPRT *xprt = NULL;
-	struct cf_conn *cd = NULL;
+	SVCXPRT *xprt;
+	struct cf_conn *cd;
 	struct sockaddr* sa = NULL;
 	struct sockopt opt;
 	int one = 1;
@@ -279,12 +279,10 @@ svc_vc_create_conn(SVCPOOL *pool, struct
 
 	return (xprt);
 cleanup_svc_vc_create:
-	if (xprt) {
-		sx_destroy(&xprt->xp_lock);
-		svc_xprt_free(xprt);
-	}
-	if (cd)
-		mem_free(cd, sizeof(*cd));
+	sx_destroy(&xprt->xp_lock);
+	svc_xprt_free(xprt);
+	mem_free(cd, sizeof(*cd));
+
 	return (NULL);
 }
 



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