Author: mav
Date: Tue Jan 14 20:18:38 2014
New Revision: 260648
URL: http://svnweb.freebsd.org/changeset/base/260648

Log:
  Fix lock leak in purely hypothetical case of TCP connection without SVC_ACK
  method.  This change should be NOP now, but it is better to be future safe.
  
  Reported by:  rmacklem

Modified:
  head/sys/fs/nfs/nfs_var.h
  head/sys/fs/nfsserver/nfs_nfsdcache.c
  head/sys/fs/nfsserver/nfs_nfsdkrpc.c

Modified: head/sys/fs/nfs/nfs_var.h
==============================================================================
--- head/sys/fs/nfs/nfs_var.h   Tue Jan 14 19:42:28 2014        (r260647)
+++ head/sys/fs/nfs/nfs_var.h   Tue Jan 14 20:18:38 2014        (r260648)
@@ -220,7 +220,7 @@ void nfsrvd_dorpc(struct nfsrv_descript 
 void nfsrvd_initcache(void);
 int nfsrvd_getcache(struct nfsrv_descript *);
 struct nfsrvcache *nfsrvd_updatecache(struct nfsrv_descript *);
-void nfsrvd_sentcache(struct nfsrvcache *, uint32_t);
+void nfsrvd_sentcache(struct nfsrvcache *, int, uint32_t);
 void nfsrvd_cleancache(void);
 void nfsrvd_refcache(struct nfsrvcache *);
 void nfsrvd_derefcache(struct nfsrvcache *);

Modified: head/sys/fs/nfsserver/nfs_nfsdcache.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdcache.c       Tue Jan 14 19:42:28 2014        
(r260647)
+++ head/sys/fs/nfsserver/nfs_nfsdcache.c       Tue Jan 14 20:18:38 2014        
(r260648)
@@ -576,18 +576,20 @@ nfsrvd_delcache(struct nfsrvcache *rp)
  * the pointer returned by nfsrvd_updatecache().
  */
 APPLESTATIC void
-nfsrvd_sentcache(struct nfsrvcache *rp, uint32_t seq)
+nfsrvd_sentcache(struct nfsrvcache *rp, int have_seq, uint32_t seq)
 {
        struct nfsrchash_bucket *hbp;
 
        KASSERT(rp->rc_flag & RC_LOCKED, ("nfsrvd_sentcache not locked"));
-       hbp = NFSRCAHASH(rp->rc_sockref);
-       mtx_lock(&hbp->mtx);
-       rp->rc_tcpseq = seq;
-       if (rp->rc_acked != RC_NO_ACK)
-               LIST_INSERT_HEAD(&hbp->tbl, rp, rc_ahash);
-       rp->rc_acked = RC_NO_ACK;
-       mtx_unlock(&hbp->mtx);
+       if (have_seq) {
+               hbp = NFSRCAHASH(rp->rc_sockref);
+               mtx_lock(&hbp->mtx);
+               rp->rc_tcpseq = seq;
+               if (rp->rc_acked != RC_NO_ACK)
+                       LIST_INSERT_HEAD(&hbp->tbl, rp, rc_ahash);
+               rp->rc_acked = RC_NO_ACK;
+               mtx_unlock(&hbp->mtx);
+       }
        nfsrc_unlock(rp);
 }
 

Modified: head/sys/fs/nfsserver/nfs_nfsdkrpc.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdkrpc.c        Tue Jan 14 19:42:28 2014        
(r260647)
+++ head/sys/fs/nfsserver/nfs_nfsdkrpc.c        Tue Jan 14 20:18:38 2014        
(r260648)
@@ -287,8 +287,8 @@ nfssvc_program(struct svc_req *rqst, SVC
                svcerr_systemerr(rqst);
        }
        if (rp != NULL) {
-               if (rqst->rq_reply_seq != 0 || SVC_ACK(xprt, NULL))
-                       nfsrvd_sentcache(rp, rqst->rq_reply_seq);
+               nfsrvd_sentcache(rp, (rqst->rq_reply_seq != 0 ||
+                   SVC_ACK(xprt, NULL)), rqst->rq_reply_seq);
        }
        svc_freereq(rqst);
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to