Skip to content

Commit 8a441de

Browse files
Peter TönzPeter Tönz
authored andcommitted
[sg fromtree] net: lwm2m: Fix seg-faults if a socket was closed in the meantime
Our application (posix-naive/debug) ran into segmentaion faults, because the socket was closed between the "wait for sockets" and the second if in the first loop. Added the check also to line 690 and 720. The other uses of sock_ctx[i] are already checked against NULL Signed-off-by: Peter Tönz <[email protected]> (cherry picked from commit 46a5912)
1 parent 726b8b8 commit 8a441de

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

subsys/net/lib/lwm2m/lwm2m_engine.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5798,13 +5798,15 @@ static void socket_loop(void)
57985798
}
57995799

58005800
for (i = 0; i < sock_nfds; ++i) {
5801-
if (sys_slist_is_empty(&sock_ctx[i]->pending_sends)) {
5801+
if (sock_ctx[i] != NULL &&
5802+
sys_slist_is_empty(&sock_ctx[i]->pending_sends)) {
58025803
next_retransmit = retransmit_request(sock_ctx[i], timestamp);
58035804
if (next_retransmit < timeout) {
58045805
timeout = next_retransmit;
58055806
}
58065807
}
5807-
if (sys_slist_is_empty(&sock_ctx[i]->pending_sends)) {
5808+
if (sock_ctx[i] != NULL &&
5809+
sys_slist_is_empty(&sock_ctx[i]->pending_sends)) {
58085810
check_notifications(sock_ctx[i], timestamp);
58095811
}
58105812
}

0 commit comments

Comments
 (0)