Index: sys/netinet/tcp_usrreq.c =================================================================== --- sys/netinet/tcp_usrreq.c +++ sys/netinet/tcp_usrreq.c @@ -2206,13 +2206,13 @@ switch (sopt->sopt_name) { #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) case TCP_MD5SIG: - if (!TCPMD5_ENABLED()) { - INP_WUNLOCK(inp); + INP_WUNLOCK(inp); + if (!TCPMD5_ENABLED()) return (ENOPROTOOPT); - } error = TCPMD5_PCBCTL(inp, sopt); if (error) return (error); + INP_WLOCK_RECHECK(inp); goto unlock_and_done; #endif /* IPSEC */ @@ -2584,10 +2584,9 @@ switch (sopt->sopt_name) { #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) case TCP_MD5SIG: - if (!TCPMD5_ENABLED()) { - INP_WUNLOCK(inp); + INP_WUNLOCK(inp); + if (!TCPMD5_ENABLED()) return (ENOPROTOOPT); - } error = TCPMD5_PCBCTL(inp, sopt); break; #endif