tcp_detach can return with inpcb lock held

Navdeep Parhar nparhar at gmail.com
Fri Jan 6 05:49:16 UTC 2012


Looks like there's a case where tcp_detach could return with the inp
lock held.  I see an XXXRW comment questioning this possibility, but
we should either add an assertion to verify that the case does not
occur, or unlock the inpcb before returning.  Or maybe both?

Regards,
Navdeep

diff -r 35bdf8d932e8 sys/netinet/tcp_usrreq.c
--- a/sys/netinet/tcp_usrreq.c  Mon Dec 19 10:08:31 2011 -0800
+++ b/sys/netinet/tcp_usrreq.c  Thu Jan 05 21:20:24 2012 -0800
@@ -204,8 +204,11 @@
                        tcp_discardcb(tp);
                        in_pcbdetach(inp);
                        in_pcbfree(inp);
-               } else
+               } else {
                        in_pcbdetach(inp);
+                       INP_WUNLOCK(inp);
+               }
+
        }
 }


More information about the freebsd-net mailing list