]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodedev: handle null return from GetIOMMUGroupDev()
authorJonathon Jongsma <jjongsma@redhat.com>
Tue, 13 Apr 2021 19:27:04 +0000 (14:27 -0500)
committerJonathon Jongsma <jjongsma@redhat.com>
Thu, 15 Apr 2021 13:51:37 +0000 (08:51 -0500)
Coverity reported that this function can return NULL, so it should be
handled properly.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/node_device/node_device_driver.c

index 180d9da5297b9acef43321de7db303a18eb6395d..8227cd83426bf4ae4c573309a573661992824410 100644 (file)
@@ -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"),