Blame SOURCES/libvirt-util-mdev-Use-a-local-variable-instead-of-a-direct-pointer-access.patch

3e5111
From 422a658bac7ffade2ac2bffb44dbe0b99919c224 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <422a658bac7ffade2ac2bffb44dbe0b99919c224@dist-git>
3e5111
From: Erik Skultety <eskultet@redhat.com>
3e5111
Date: Thu, 4 May 2017 13:49:59 +0200
3e5111
Subject: [PATCH] util: mdev: Use a local variable instead of a direct pointer
3e5111
 access
3e5111
3e5111
Use a local variable to hold data, rather than accessing the pointer
3e5111
after calling virMediatedDeviceListAdd (therefore VIR_APPEND_ELEMENT).
3e5111
Although not causing an issue at the moment, this change is a necessary
3e5111
prerequisite for tweaking virMediatedDeviceListAdd in a separate patch,
3e5111
which will take a reference for the source pointer (instead of pointer
3e5111
value) and will clear it along the way.
3e5111
3e5111
Signed-off-by: Erik Skultety <eskultet@redhat.com>
3e5111
Reviewed-by: Laine Stump <laine@laine.org>
3e5111
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1446455
3e5111
(cherry picked from commit 2739a983f235f0d92d210800d61bd1a195f01850)
3e5111
Signed-off-by: Erik Skultety <eskultet@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/util/virmdev.c | 5 +++--
3e5111
 1 file changed, 3 insertions(+), 2 deletions(-)
3e5111
3e5111
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
3e5111
index 2a1ade739..c1499d238 100644
3e5111
--- a/src/util/virmdev.c
3e5111
+++ b/src/util/virmdev.c
3e5111
@@ -447,20 +447,21 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
3e5111
     virObjectLock(dst);
3e5111
     for (i = 0; i < count; i++) {
3e5111
         virMediatedDevicePtr mdev = virMediatedDeviceListGet(src, i);
3e5111
+        const char *mdev_path = mdev->path;
3e5111
 
3e5111
         if (virMediatedDeviceIsUsed(mdev, dst) ||
3e5111
             virMediatedDeviceSetUsedBy(mdev, drvname, domname) < 0)
3e5111
             goto cleanup;
3e5111
 
3e5111
         /* Copy mdev references to the driver list:
3e5111
-         * - caller is responsible for NOT freeing devices in @list on success
3e5111
+         * - caller is responsible for NOT freeing devices in @src on success
3e5111
          * - we're responsible for performing a rollback on failure
3e5111
          */
3e5111
         if (virMediatedDeviceListAdd(dst, mdev) < 0)
3e5111
             goto rollback;
3e5111
 
3e5111
         VIR_DEBUG("'%s' added to list of active mediated devices used by '%s'",
3e5111
-                  mdev->path, domname);
3e5111
+                  mdev_path, domname);
3e5111
     }
3e5111
 
3e5111
     ret = 0;
3e5111
-- 
3e5111
2.13.0
3e5111