Skip to content

Commit 13b2e5b

Browse files
chyu313cfriedt
authored andcommitted
net: ip: Fix assertion failure when tcp_send_data()
When tcp_send_data() is called to resend data, but there is no data to resend, zero length packet is allocated and NULL net_buf is passed to net_buf_frag_insert() in which assertion fails. Fixes zephyrproject-rtos#36578 Signed-off-by: Chih Hung Yu <[email protected]>
1 parent ccdb3f8 commit 13b2e5b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

subsys/net/ip/tcp2.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,11 @@ static int tcp_send_data(struct tcp *conn)
925925
len = MIN3(conn->send_data_total - conn->unacked_len,
926926
conn->send_win - conn->unacked_len,
927927
conn_mss(conn));
928+
if (len == 0) {
929+
NET_DBG("conn: %p no data to send", conn);
930+
ret = -ENODATA;
931+
goto out;
932+
}
928933

929934
pkt = tcp_pkt_alloc(conn, len);
930935
if (!pkt) {
@@ -1070,6 +1075,9 @@ static void tcp_resend_data(struct k_work *work)
10701075

10711076
goto out;
10721077
}
1078+
} else if (ret == -ENODATA) {
1079+
conn->data_mode = TCP_DATA_MODE_SEND;
1080+
goto out;
10731081
}
10741082

10751083
k_work_reschedule_for_queue(&tcp_work_q, &conn->send_data_timer,

0 commit comments

Comments
 (0)