Skip to content

Commit 13a7baf

Browse files
jukkarnashif
authored andcommitted
net: tcp2: Bail out if new connection cannot be created
If there is some error during connection creation, just bail out in order to avoid null pointer access. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 4e3060a commit 13a7baf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

subsys/net/ip/tcp2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,10 @@ static enum net_verdict tcp_recv(struct net_conn *net_conn,
10231023
struct tcp *conn_old = ((struct net_context *)user_data)->tcp;
10241024

10251025
conn = tcp_conn_new(pkt);
1026+
if (!conn) {
1027+
NET_ERR("Cannot allocate a new TCP connection");
1028+
goto in;
1029+
}
10261030

10271031
net_ipaddr_copy(&conn_old->context->remote, &conn->dst.sa);
10281032

0 commit comments

Comments
 (0)