51 lines
1.9 KiB
Diff
51 lines
1.9 KiB
Diff
From bad40f7148a5849e84e9cdc341ff1fa03dc94fc6 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <bad40f7148a5849e84e9cdc341ff1fa03dc94fc6@dist-git>
|
|
From: Thomas Huth <thuth@redhat.com>
|
|
Date: Tue, 11 May 2021 14:10:27 +0200
|
|
Subject: [PATCH] hostdev: Update mdev pointer reference after checking device
|
|
type
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
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>
|
|
(cherry picked from commit 964738cff3d949d90fc5c3317a2618fcd8d217b4)
|
|
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1940449
|
|
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
Message-Id: <20210511121028.304070-2-thuth@redhat.com>
|
|
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
---
|
|
src/util/virhostdev.c | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
|
|
index 9596482146..b7050e99e4 100644
|
|
--- a/src/util/virhostdev.c
|
|
+++ b/src/util/virhostdev.c
|
|
@@ -2030,11 +2030,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;
|
|
--
|
|
2.31.1
|
|
|