diff --git a/usrsctplib/user_socketvar.h b/usrsctplib/user_socketvar.h index e8eccc7fb..b46154ed8 100755 --- a/usrsctplib/user_socketvar.h +++ b/usrsctplib/user_socketvar.h @@ -403,6 +403,7 @@ void sofree(struct socket *so); #define soref(so) do { \ SOCK_LOCK_ASSERT(so); \ + KASSERT((so)->so_count >= 0, ("soref")); \ ++(so)->so_count; \ } while (0) @@ -410,8 +411,10 @@ void sofree(struct socket *so); ACCEPT_LOCK_ASSERT(); \ SOCK_LOCK_ASSERT(so); \ KASSERT((so)->so_count > 0, ("sorele")); \ - if (--(so)->so_count == 0) \ + if (--(so)->so_count == 0) { \ + (so)->so_count = -1; \ sofree(so); \ + } \ else { \ SOCK_UNLOCK(so); \ ACCEPT_UNLOCK(); \