From dcb7abc7179ce9d3b71030380154380472b6b319 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 12 Jun 2017 13:46:54 -0700 Subject: [PATCH] vhost_iommu: handle opendir() failure Change-Id: I82ce702ab1af83c2f5c0197a9766437f0f728dce Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/365067 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/vhost/vhost_iommu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/vhost/vhost_iommu.c b/lib/vhost/vhost_iommu.c index a785e3316..24f943793 100644 --- a/lib/vhost/vhost_iommu.c +++ b/lib/vhost/vhost_iommu.c @@ -91,6 +91,11 @@ vfio_cfg_init(void) } dir = opendir("/proc/self/fd"); + if (!dir) { + SPDK_ERRLOG("Failed to open /proc/self/fd (%d)\n", errno); + return -1; + } + while ((d = readdir(dir)) != NULL) { if (d->d_type != DT_LNK) continue;