From patchwork Fri Mar 16 15:22:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 36173 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 08B4F7289; Fri, 16 Mar 2018 16:22:47 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 793075F2B for ; Fri, 16 Mar 2018 16:22:45 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 16 Mar 2018 17:23:24 +0200 Received: from dev-r630-06.mtbc.labs.mlnx (dev-r630-06.mtbc.labs.mlnx [10.12.205.180]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w2GFMhH5016489; Fri, 16 Mar 2018 17:22:43 +0200 Received: from dev-r630-06.mtbc.labs.mlnx (localhost [127.0.0.1]) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7) with ESMTP id w2GFMgFT019859; Fri, 16 Mar 2018 23:22:42 +0800 Received: (from xuemingl@localhost) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id w2GFMewD019858; Fri, 16 Mar 2018 23:22:40 +0800 From: Xueming Li To: Nelio Laranjeiro , Adrien Mazarguil , Shahaf Shuler Cc: Xueming Li , dev@dpdk.org Date: Fri, 16 Mar 2018 23:22:27 +0800 Message-Id: <20180316152227.19813-1-xuemingl@mellanox.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20180316102748.10864-1-xuemingl@mellanox.com> References: <20180316102748.10864-1-xuemingl@mellanox.com> Subject: [dpdk-dev] [PATCH v1] net/mlx5: fix existing file removal X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" There is no guarantee that the file won't be removed by external user/application between the stat() and remove() syscalls, remove() will fail if the file no longer exists. Fixes: f8b9a3bad467 ("net/mlx5: install a socket to exchange a file descriptor") Signed-off-by: Xueming Li Acked-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_socket.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5_socket.c b/drivers/net/mlx5/mlx5_socket.c index 61c1a4a..fb80fb3 100644 --- a/drivers/net/mlx5/mlx5_socket.c +++ b/drivers/net/mlx5/mlx5_socket.c @@ -32,7 +32,6 @@ }; int ret; int flags; - struct stat file_stat; /* * Initialise the socket to communicate with the secondary @@ -52,9 +51,7 @@ goto out; snprintf(sun.sun_path, sizeof(sun.sun_path), "/var/tmp/%s_%d", MLX5_DRIVER_NAME, priv->primary_socket); - ret = stat(sun.sun_path, &file_stat); - if (!ret) - claim_zero(remove(sun.sun_path)); + remove(sun.sun_path); ret = bind(priv->primary_socket, (const struct sockaddr *)&sun, sizeof(sun)); if (ret < 0) {