render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 422a658bac7ffade2ac2bffb44dbe0b99919c224 Mon Sep 17 00:00:00 2001
Message-Id: <422a658bac7ffade2ac2bffb44dbe0b99919c224@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Thu, 4 May 2017 13:49:59 +0200
Subject: [PATCH] util: mdev: Use a local variable instead of a direct pointer
 access

Use a local variable to hold data, rather than accessing the pointer
after calling virMediatedDeviceListAdd (therefore VIR_APPEND_ELEMENT).
Although not causing an issue at the moment, this change is a necessary
prerequisite for tweaking virMediatedDeviceListAdd in a separate patch,
which will take a reference for the source pointer (instead of pointer
value) and will clear it along the way.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=1446455
(cherry picked from commit 2739a983f235f0d92d210800d61bd1a195f01850)
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/util/virmdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index 2a1ade739..c1499d238 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -447,20 +447,21 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
     virObjectLock(dst);
     for (i = 0; i < count; i++) {
         virMediatedDevicePtr mdev = virMediatedDeviceListGet(src, i);
+        const char *mdev_path = mdev->path;
 
         if (virMediatedDeviceIsUsed(mdev, dst) ||
             virMediatedDeviceSetUsedBy(mdev, drvname, domname) < 0)
             goto cleanup;
 
         /* Copy mdev references to the driver list:
-         * - caller is responsible for NOT freeing devices in @list on success
+         * - caller is responsible for NOT freeing devices in @src on success
          * - we're responsible for performing a rollback on failure
          */
         if (virMediatedDeviceListAdd(dst, mdev) < 0)
             goto rollback;
 
         VIR_DEBUG("'%s' added to list of active mediated devices used by '%s'",
-                  mdev->path, domname);
+                  mdev_path, domname);
     }
 
     ret = 0;
-- 
2.13.0