From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?N=E9lio?= Laranjeiro Subject: Re: [PATCH v1] net/mlx5: fix existing file removal Date: Fri, 16 Mar 2018 16:37:44 +0100 Message-ID: <20180316153744.lua4zr54er5v5p7g@laranjeiro-vm.dev.6wind.com> References: <20180316102748.10864-1-xuemingl@mellanox.com> <20180316152227.19813-1-xuemingl@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: Adrien Mazarguil , Shahaf Shuler , dev@dpdk.org To: Xueming Li Return-path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id C099C5F2B for ; Fri, 16 Mar 2018 16:38:47 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id 5so3853922wmh.0 for ; Fri, 16 Mar 2018 08:38:47 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20180316152227.19813-1-xuemingl@mellanox.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Mar 16, 2018 at 11:22:27PM +0800, Xueming Li wrote: > 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) { > -- > 1.8.3.1 > -- Nélio Laranjeiro 6WIND