From: Michael Baum Date: Wed, 27 May 2020 08:37:55 +0000 (+0000) Subject: net/mlx5: fix socket close X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=50181d99656490844c2565560c4b5eba9c657979;p=dpdk.git net/mlx5: fix socket close 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 leak. 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 Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/mlx5_socket.c b/drivers/net/mlx5/mlx5_socket.c index f473795604..08af905126 100644 --- a/drivers/net/mlx5/mlx5_socket.c +++ b/drivers/net/mlx5/mlx5_socket.c @@ -109,7 +109,7 @@ mlx5_pmd_socket_handle(void *cb __rte_unused) DRV_LOG(WARNING, "failed to send response %s", strerror(errno)); error: - if (conn_sock > 0) + if (conn_sock >= 0) close(conn_sock); if (file) fclose(file);