net: tcp: validate pointer before dereferencing it

See https://habr.com/en/company/pvs-studio/blog/495284/ fragment 8.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-04-05 11:23:16 -05:00 committed by Anas Nashif
commit cbce6dde4c

View file

@ -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);