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 <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Jonathon Jongsma 2021-04-13 14:27:04 -05:00
parent 12850ed257
commit 5c4b2bf770

View 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"),