Skip to content

Commit

Permalink
Assert if soref() is called on an already-released socket.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLennox committed Feb 29, 2024
1 parent 848eca8 commit e719a63
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion usrsctplib/user_socketvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,18 @@ void sofree(struct socket *so);

#define soref(so) do { \
SOCK_LOCK_ASSERT(so); \
KASSERT((so)->so_count => 0, ("soref")); \
++(so)->so_count; \
} while (0)

#define sorele(so) do { \
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(); \
Expand Down

0 comments on commit e719a63

Please sign in to comment.