From a8b73aa2871449a6b00f44c604741267e7f2c1fd Mon Sep 17 00:00:00 2001 From: Flavio Santes Date: Sun, 11 Dec 2016 00:40:56 -0600 Subject: [PATCH] tcp: Validate net_context_put return code Validate the return code of net_context_put and add debug information in case any error is detected. This patch fixes the error reported by Coverity: Error handling issues (CHECKED_RETURN) Calling "net_context_put" without checking return value (as is done elsewhere 4 out of 5 times). Coverity-CID: 157833 Change-Id: Ia4a87cc08094bee465c8828411d7c1311481695a Signed-off-by: Flavio Santes --- subsys/net/ip/tcp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subsys/net/ip/tcp.c b/subsys/net/ip/tcp.c index b55a0504a87..aeb5ae1ef99 100644 --- a/subsys/net/ip/tcp.c +++ b/subsys/net/ip/tcp.c @@ -723,10 +723,14 @@ void net_tcp_init(void) static void fin_timeout(struct k_work *work) { struct net_tcp *tcp = CONTAINER_OF(work, struct net_tcp, fin_timer); + int rc; NET_DBG("Remote peer didn't confirm connection close"); - net_context_put(tcp->context); + rc = net_context_put(tcp->context); + if (rc < 0) { + NET_DBG("Cannot close TCP context"); + } } #if NET_DEBUG