[4/6] net/mlx5: fix socket handle closing

Message ID 1590568677-11662-4-git-send-email-michaelba@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Series [1/6] net/mlx5: fix hairpin Tx queue creation error flow |


Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Michael Baum May 27, 2020, 8:37 a.m. UTC
  The mlx5_pmd_socket_handle function calls the accept function that
returns the socket descriptor into the conn_sock variable. The socket
descriptor value can be 0 (according to accept API) or positive and so
immediately after calling the function it checks whether conn_sock < 0.
Later in the function when other things fail it jumps to the error label
and release previously allocated resources (such as socket or file).

During the resource release, it checks whether the variable conn_sock
containing the socket descriptor is positive and if it is, it releases
it. However, in this check it misses the case where conn_sock == 0, in
this case the socket will not be released and there will be a Resource

Extend the close condition for 0 value too.

Fixes: e6cdc54cc0ef ("net/mlx5: add socket server for external tools")
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
 drivers/net/mlx5/mlx5_socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/drivers/net/mlx5/mlx5_socket.c b/drivers/net/mlx5/mlx5_socket.c
index f473795..08af905 100644
--- a/drivers/net/mlx5/mlx5_socket.c
+++ b/drivers/net/mlx5/mlx5_socket.c
@@ -109,7 +109,7 @@ 
 		DRV_LOG(WARNING, "failed to send response %s",
-	if (conn_sock > 0)
+	if (conn_sock >= 0)
 	if (file)