[dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_blk: fix the TOCTOU
Bruce Richardson
bruce.richardson at intel.com
Tue Nov 26 11:25:55 CET 2019
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 at dpdk.org
>
> Signed-off-by: Jin Yu <jin.yu at intel.com>
> ---
> 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
More information about the stable
mailing list