From cbce6dde4c7ee9ba6ab0f3ad9e5eca586a6c2c21 Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Sun, 5 Apr 2020 11:23:16 -0500 Subject: [PATCH] net: tcp: validate pointer before dereferencing it See https://habr.com/en/company/pvs-studio/blog/495284/ fragment 8. Signed-off-by: Peter Bigot --- subsys/net/ip/tcp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/subsys/net/ip/tcp.c b/subsys/net/ip/tcp.c index 6a2dc0aac59..7d26f98eced 100644 --- a/subsys/net/ip/tcp.c +++ b/subsys/net/ip/tcp.c @@ -1506,6 +1506,7 @@ int net_tcp_put(struct net_context *context) if (net_context_get_ip_proto(context) == IPPROTO_TCP) { if ((net_context_get_state(context) == NET_CONTEXT_CONNECTED || net_context_get_state(context) == NET_CONTEXT_LISTENING) + && context->tcp && !context->tcp->fin_rcvd) { NET_DBG("TCP connection in active close, not " "disposing yet (waiting %dms)", FIN_TIMEOUT);