There are few places where a virDomainHostdevDef->source.subsys
is accessed without ->mode being checked. Mind you,
virDomainHostdevDef can be also in
VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES mode.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 3 ++-
src/conf/domain_validate.c | 3 ++-
src/security/virt-aa-helper.c | 4 ++++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1f14ef6f23..9d819c3dab 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5099,7 +5099,8 @@ virDomainDriveAddressIsUsedByHostdev(const virDomainDef *def,
for (i = 0; i < def->nhostdevs; i++) {
hostdev = def->hostdevs[i];
- if (hostdev->source.subsys.type != type ||
+ if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+ hostdev->source.subsys.type != type ||
hostdev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE)
continue;
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index b050f21edb..53d920b2b3 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -1283,7 +1283,8 @@ virDomainDefHostdevValidate(const virDomainDef *def)
}
}
- if (dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV &&
+ if (dev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV &&
dev->source.subsys.u.mdev.ramfb == VIR_TRISTATE_SWITCH_ON) {
if (ramfbEnabled) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index c50629d096..4638451183 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1049,6 +1049,10 @@ get_files(vahControl * ctl)
if (ctl->def->hostdevs[i]) {
virDomainHostdevDef *dev = ctl->def->hostdevs[i];
virDomainHostdevSubsysUSB *usbsrc = &dev->source.subsys.u.usb;
+
+ if (dev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+ continue;
+
switch (dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
virUSBDevice *usb =
--
2.41.0