tcp/usrreq: In netisrs, if so_pcb is non-NULL, then tp is non-NULL
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 18 Oct 2015 14:02:53 +0000 (22:02 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 20 Oct 2015 07:19:53 +0000 (15:19 +0800)
sys/netinet/tcp_usrreq.c

index 975b265..ee981f3 100644 (file)
@@ -245,17 +245,13 @@ tcp_usr_detach(netmsg_t msg)
         * If the inp is already detached or never attached, it may have
         * been due to an async close or async attach failure.  Just return
         * as if no error occured.
-        *
-        * It's possible for the tcpcb (tp) to disconnect from the inp due
-        * to tcp_drop()->tcp_close() being called.  This may occur *after*
-        * the detach message has been queued so we may find a NULL tp here.
         */
        if (inp) {
-               if ((tp = intotcpcb(inp)) != NULL) {
-                       TCPDEBUG1();
-                       tp = tcp_disconnect(tp);
-                       TCPDEBUG2(PRU_DETACH);
-               }
+               tp = intotcpcb(inp);
+               KASSERT(tp != NULL, ("tcp_usr_detach: tp is NULL"));
+               TCPDEBUG1();
+               tp = tcp_disconnect(tp);
+               TCPDEBUG2(PRU_DETACH);
        }
        lwkt_replymsg(&msg->lmsg, error);
 }