From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 65D0BA04C3; Tue, 26 Nov 2019 11:26:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2DF1F2B96; Tue, 26 Nov 2019 11:26:04 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 134722B88; Tue, 26 Nov 2019 11:26:01 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2019 02:25:59 -0800 X-IronPort-AV: E=Sophos;i="5.69,245,1571727600"; d="scan'208";a="202675513" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.46]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Nov 2019 02:25:58 -0800 Date: Tue, 26 Nov 2019 10:25:55 +0000 From: Bruce Richardson To: Jin Yu Cc: Maxime Coquelin , Tiwei Bie , Zhihong Wang , dev@dpdk.org, stable@dpdk.org Message-ID: <20191126102555.GA1629@bricha3-MOBL.ger.corp.intel.com> References: <20191126153214.7952-1-jin.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191126153214.7952-1-jin.yu@intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) Subject: Re: [dpdk-dev] [PATCH] examples/vhost_blk: fix the TOCTOU 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" On Tue, Nov 26, 2019 at 11:32:14PM +0800, Jin Yu wrote: > Fix the time of check time of use warning in example code > > Coverity issue: 350589 158663 > Fixes: c19beb3f38cd ("examples/vhost_blk: introduce vhost storage sample") > Cc: stable@dpdk.org > > Signed-off-by: Jin Yu > --- > examples/vhost_blk/vhost_blk.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c > index 3182a488b..bcb4ebb0b 100644 > --- a/examples/vhost_blk/vhost_blk.c > +++ b/examples/vhost_blk/vhost_blk.c > @@ -993,11 +993,7 @@ vhost_blk_ctrlr_construct(const char *ctrlr_name) > } > snprintf(dev_pathname, sizeof(dev_pathname), "%s/%s", path, ctrlr_name); > > - if (access(dev_pathname, F_OK) != -1) { > - if (unlink(dev_pathname) != 0) > - rte_exit(EXIT_FAILURE, "Cannot remove %s.\n", > - dev_pathname); > - } > + unlink(dev_pathname); > The original code did an exit if the delete failed, do you intend there to be a behaviour change here? You can probably get the same behaviour if you check the errno on an unlink failure, e.g. ENOENT means file doesn't exist. If not having the app exit on unlink failure is reasonable behaviour then ignore this comment. Regards, /Bruce