From patchwork Wed Jul 6 17:48:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 113755 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E8D02A0540; Wed, 6 Jul 2022 19:49:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA6EF40E50; Wed, 6 Jul 2022 19:49:01 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id C793040687 for ; Wed, 6 Jul 2022 19:48:59 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1004) id 0D0CE20DDCCE; Wed, 6 Jul 2022 10:48:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0D0CE20DDCCE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1657129739; bh=uBkdcHwOSFMHIwUlGeYhw6ZkbW6WdpwOYUpVOt6ysr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=e0qjBffSVlSJ8Gm1dpIVDlGCkR7Cjon8kAnKDopUnq5LaHY42o2HLHG3t8SE4QdqY pc7J4NMOhjDAqWCUsdxYrOaYWvZ8hoRMF5ea3Rkf+3p2ZHxo00lh6XbIup8V0k5t2x JFCroZ5GqDw1+aX8qd2lpyqN9UUlUjXVecSVO2ik= From: longli@linuxonhyperv.com To: Matan Azrad , Ferruh Yigit Cc: dev@dpdk.org, Karanjot Singh , Long Li Subject: [Patch v2] net/mlx5: fix verbs fd leak in the secondary process Date: Wed, 6 Jul 2022 10:48:53 -0700 Message-Id: <1657129733-12126-2-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1657129733-12126-1-git-send-email-longli@linuxonhyperv.com> References: <1657129733-12126-1-git-send-email-longli@linuxonhyperv.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: longli@microsoft.com Errors-To: dev-bounces@dpdk.org From: Long Li FDs passed from rte_mp_msg are duplicated to the secondary process and need to be closed. Fixes: 9a8ab29b84 ("net/mlx5: replace IPC socket with EAL API") Signed-off-by: Long Li Acked-by: Viacheslav Ovsiienko --- Change in v2: handle error case where mlx5_proc_priv_init() might fail drivers/net/mlx5/linux/mlx5_mp_os.c | 6 +++++- drivers/net/mlx5/linux/mlx5_os.c | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_mp_os.c b/drivers/net/mlx5/linux/mlx5_mp_os.c index c448a3e9eb..0ba2208fe0 100644 --- a/drivers/net/mlx5/linux/mlx5_mp_os.c +++ b/drivers/net/mlx5/linux/mlx5_mp_os.c @@ -177,14 +177,18 @@ struct rte_mp_msg mp_res; mlx5_tx_uar_uninit_secondary(dev); mlx5_proc_priv_uninit(dev); ret = mlx5_proc_priv_init(dev); - if (ret) + if (ret) { + close(mp_msg->fds[0]); return -rte_errno; + } ret = mlx5_tx_uar_init_secondary(dev, mp_msg->fds[0]); if (ret) { + close(mp_msg->fds[0]); mlx5_proc_priv_uninit(dev); return -rte_errno; } } + close(mp_msg->fds[0]); rte_mb(); mp_init_msg(&priv->mp_id, &mp_res, param->type); res->result = 0; diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index c29fe3d92b..69ae3c944b 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -933,6 +933,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name); if (rte_eal_process_type() == RTE_PROC_SECONDARY) { struct mlx5_mp_id mp_id; + int fd; eth_dev = rte_eth_dev_attach_secondary(name); if (eth_dev == NULL) { @@ -949,11 +950,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, return NULL; mlx5_mp_id_init(&mp_id, eth_dev->data->port_id); /* Receive command fd from primary process */ - err = mlx5_mp_req_verbs_cmd_fd(&mp_id); - if (err < 0) + fd = mlx5_mp_req_verbs_cmd_fd(&mp_id); + if (fd < 0) goto err_secondary; /* Remap UAR for Tx queues. */ - err = mlx5_tx_uar_init_secondary(eth_dev, err); + err = mlx5_tx_uar_init_secondary(eth_dev, fd); + close(fd); if (err) goto err_secondary; /*