[libvirt PATCH v2 3/3] nodedev: handle null return from GetIOMMUGroupDev()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Coverity reported that this function can return NULL, so it should be
handled properly.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---

Changes in v2:
- remove virReportError() to avoid error-stacking per review from Erik

 src/node_device/node_device_driver.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 180d9da529..8227cd8342 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -1207,9 +1207,14 @@ nodeDeviceDestroy(virNodeDevicePtr device)
          * shouldn't try to remove the device. */
         g_autofree char *vfiogroup =
             virMediatedDeviceGetIOMMUGroupDev(def->caps->data.mdev.uuid);
-        VIR_AUTOCLOSE fd = open(vfiogroup, O_RDONLY);
+        VIR_AUTOCLOSE fd = -1;
         g_autofree char *errmsg = NULL;
 
+        if (!vfiogroup)
+            goto cleanup;
+
+        fd = open(vfiogroup, O_RDONLY);
+
         if (fd < 0 && errno == EBUSY) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Unable to destroy '%s': device in use"),
-- 
2.26.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux