Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions usrsctplib/user_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static void
sodealloc(struct socket *so)
{

KASSERT(so->so_count == 0, ("sodealloc(): so_count %d", so->so_count));
KASSERT(so->so_count <= 0, ("sodealloc(): so_count %d", so->so_count));
KASSERT(so->so_pcb == NULL, ("sodealloc(): so_pcb != NULL"));

SOCKBUF_COND_DESTROY(&so->so_snd);
Expand All @@ -254,7 +254,7 @@ sofree(struct socket *so)
/* SS_NOFDREF unset in accept call. this condition seems irrelevant
* for __Userspace__...
*/
if (so->so_count != 0 ||
if (so->so_count > 0 ||
(so->so_state & SS_PROTOREF) || (so->so_qstate & SQ_COMP)) {
SOCK_UNLOCK(so);
ACCEPT_UNLOCK();
Expand Down
2 changes: 2 additions & 0 deletions usrsctplib/user_socketvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
SCTPDBG(SCTP_DEBUG_USR, "soref(%p) -> %d, %s:%s:%d\n", \
(so), (so)->so_count, \
Expand All @@ -417,6 +418,7 @@ void sofree(struct socket *so);
SCTPDBG(SCTP_DEBUG_USR, "sorele(%p) -> %d, %s:%s:%d\n", \
(so), (so)->so_count, \
__func__, __FILE__, __LINE__) \
(so)->so_count = -1; \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we actually do this, sofree() will return early, since so->so_count != 0 would be true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right; see my follow-up commit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix merge conflict.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rebased it.

sofree(so); \
} \
else { \
Expand Down