Skip to content

Commit 6ceb672

Browse files
mwerschyfabiobaltieri
authored andcommitted
net: sockets: ensure socket obj core is only linked once
Repeated linking of socket object cores can corrupt the linked list. Fixes: #93587 Signed-off-by: Malte Werschy <[email protected]>
1 parent b0e6471 commit 6ceb672

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

subsys/net/lib/sockets/socket_obj_core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ static void sock_obj_core_init_and_link(struct sock_obj *sock)
6666
type_init_done = true;
6767
}
6868

69-
k_obj_core_init_and_link(K_OBJ_CORE(sock), &sock_obj_type);
70-
k_obj_core_stats_register(K_OBJ_CORE(sock), &sock->stats,
71-
sizeof(struct sock_obj_type_raw_stats));
72-
7369
/* If the socket was closed and we re-opened it again, then clear
7470
* the statistics.
7571
*/
7672
if (sock->init_done) {
7773
k_obj_core_stats_reset(K_OBJ_CORE(sock));
74+
} else {
75+
k_obj_core_init_and_link(K_OBJ_CORE(sock), &sock_obj_type);
76+
k_obj_core_stats_register(K_OBJ_CORE(sock), &sock->stats,
77+
sizeof(struct sock_obj_type_raw_stats));
7878
}
7979

8080
sock->init_done = true;

0 commit comments

Comments
 (0)