Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jun 2018 04:57:41 +0000 (UTC)
From:      Matt Macy <mmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334756 - head/sys/kern
Message-ID:  <201806070457.w574vfKg078644@repo.freebsd.org>

Next in thread | Raw E-Mail | Index | Archive | Help
Author: mmacy
Date: Thu Jun  7 04:57:40 2018
New Revision: 334756
URL: https://svnweb.freebsd.org/changeset/base/334756

Log:
  AF_UNIX: check for unp == unp2 on disconnect

Modified:
  head/sys/kern/uipc_usrreq.c

Modified: head/sys/kern/uipc_usrreq.c
==============================================================================
--- head/sys/kern/uipc_usrreq.c	Thu Jun  7 04:03:19 2018	(r334755)
+++ head/sys/kern/uipc_usrreq.c	Thu Jun  7 04:57:40 2018	(r334756)
@@ -872,21 +872,19 @@ uipc_disconnect(struct socket *so)
 		UNP_PCB_UNLOCK(unp);
 		return (0);
 	}
-	if (unp == unp2) {
-		if (unp_pcb_rele(unp) == 0)
+	if (__predict_true(unp != unp2)) {
+		unp_pcb_owned_lock2(unp, unp2, freed);
+		if (__predict_false(freed)) {
 			UNP_PCB_UNLOCK(unp);
+			return (0);
+		}
+		unp_pcb_hold(unp2);
 	}
-	unp_pcb_owned_lock2(unp, unp2, freed);
-	if (__predict_false(freed)) {
-		UNP_PCB_UNLOCK(unp);
-		return (0);
-	}
-	unp_pcb_hold(unp2);
 	unp_pcb_hold(unp);
 	unp_disconnect(unp, unp2);
 	if (unp_pcb_rele(unp) == 0)
 		UNP_PCB_UNLOCK(unp);
-	if (unp_pcb_rele(unp2) == 0)
+	if ((unp != unp2) && unp_pcb_rele(unp2) == 0)
 		UNP_PCB_UNLOCK(unp2);
 	return (0);
 }



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?201806070457.w574vfKg078644>