net/nfp: fix resource leak on errors
authorAlejandro Lucero <alejandro.lucero@netronome.com>
Mon, 8 Apr 2019 11:02:04 +0000 (12:02 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 12 Apr 2019 09:02:02 +0000 (11:02 +0200)
Not closing the socket implies a resource leak.

Coverity issue: 336865
Fixes: 29a62d1476b6 ("net/nfp: add CPP bridge as service")
Cc: stable@dpdk.org
Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
drivers/net/nfp/nfp_net.c

index d4c94d7..b2ff03a 100644 (file)
@@ -3301,6 +3301,7 @@ nfp_cpp_bridge_service_func(void *args)
        if (ret < 0) {
                RTE_LOG(ERR, PMD, "%s: bind error (%d). Service failed\n",
                                  __func__, errno);
+               close(sockfd);
                return ret;
        }
 
@@ -3308,6 +3309,7 @@ nfp_cpp_bridge_service_func(void *args)
        if (ret < 0) {
                RTE_LOG(ERR, PMD, "%s: listen error(%d). Service failed\n",
                                  __func__, errno);
+               close(sockfd);
                return ret;
        }
 
@@ -3317,6 +3319,7 @@ nfp_cpp_bridge_service_func(void *args)
                        RTE_LOG(ERR, PMD, "%s: accept call error (%d)\n",
                                          __func__, errno);
                        RTE_LOG(ERR, PMD, "%s: service failed\n", __func__);
+                       close(sockfd);
                        return -EIO;
                }