On 4/13/21 4:49 PM, Jonathon Jongsma wrote:
Coverity reported that this function can return NULL, so it should be
handled properly.
Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
Reviewed-by: Laine Stump <laine@xxxxxxxxxx>
---
src/node_device/node_device_driver.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 5f8995172d..2fcebd065b 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -1192,9 +1192,18 @@ 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) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to determine iommu group for '%s'"),
+ def->name);
+ goto cleanup;
+ }
+
+ fd = open(vfiogroup, O_RDONLY);
+
if (fd < 0 && errno == EBUSY) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to destroy '%s': device in use"),