From: Jonathon Jongsma Date: Tue, 13 Apr 2021 19:27:04 +0000 (-0500) Subject: nodedev: handle null return from GetIOMMUGroupDev() X-Git-Tag: v7.3.0-rc1~215 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c4b2bf7709ef517502fccdf3d92b166f8f82ba4;p=thirdparty%2Flibvirt.git nodedev: handle null return from GetIOMMUGroupDev() Coverity reported that this function can return NULL, so it should be handled properly. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety --- 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"),