mirror of https://gitee.com/openkylin/libvirt.git
hostdev: Update mdev pointer reference after checking device type
We set the pointer to some garbage packed structure data without knowing whether we were actually handling the type of device we expected to be handling. On its own, this was harmless, because we'd never use the pointer as we'd skip the device if it were not the expected type. However, it's better to make the logic even more explicit - we first check the device and only when we're sure we have the expected type we then update the pointer shortcut. Signed-off-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
49b5ebad9c
commit
964738cff3
|
@ -1980,11 +1980,11 @@ virHostdevReAttachMediatedDevices(virHostdevManagerPtr mgr,
|
|||
virDomainHostdevSubsysMediatedDevPtr mdevsrc;
|
||||
virDomainHostdevDefPtr hostdev = hostdevs[i];
|
||||
|
||||
mdevsrc = &hostdev->source.subsys.u.mdev;
|
||||
|
||||
if (!virHostdevIsMdevDevice(hostdev))
|
||||
continue;
|
||||
|
||||
mdevsrc = &hostdev->source.subsys.u.mdev;
|
||||
|
||||
if (!(mdev = virMediatedDeviceNew(mdevsrc->uuidstr,
|
||||
mdevsrc->model)))
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue