Blame SOURCES/libvirt-util-avoid-manual-VIR_FREE-of-a-g_autofree-pointer-in-virPCIGetName.patch

7548c0
From 4eed301c16a93fdcc6867823a88406e9578c1da7 Mon Sep 17 00:00:00 2001
7548c0
Message-Id: <4eed301c16a93fdcc6867823a88406e9578c1da7@dist-git>
7548c0
From: Laine Stump <laine@redhat.com>
7548c0
Date: Thu, 28 Jan 2021 23:17:28 -0500
7548c0
Subject: [PATCH] util: avoid manual VIR_FREE of a g_autofree pointer in
7548c0
 virPCIGetName()
7548c0
7548c0
thisPhysPortID is only used inside a conditional, so reduce its scope
7548c0
to just the body of that conditional, which will eliminate the need
7548c0
for the undesirable manual VIR_FREE().
7548c0
7548c0
https://bugzilla.redhat.com/1918708
7548c0
Signed-off-by: Laine Stump <laine@redhat.com>
7548c0
Reviewed-by: Erik Skultety <eskultet@redhat.com>
7548c0
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
7548c0
(cherry picked from commit fefd478644a2ad2951491552081cd53b6ecd4223)
7548c0
Message-Id: <20210129041729.1076345-3-laine@redhat.com>
7548c0
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7548c0
---
7548c0
 src/util/virpci.c | 4 ++--
7548c0
 1 file changed, 2 insertions(+), 2 deletions(-)
7548c0
7548c0
diff --git a/src/util/virpci.c b/src/util/virpci.c
7548c0
index 0b1222373e..00377eed31 100644
7548c0
--- a/src/util/virpci.c
7548c0
+++ b/src/util/virpci.c
7548c0
@@ -2440,7 +2440,6 @@ virPCIGetNetName(const char *device_link_sysfs_path,
7548c0
 {
7548c0
     g_autofree char *pcidev_sysfs_net_path = NULL;
7548c0
     g_autofree char *firstEntryName = NULL;
7548c0
-    g_autofree char *thisPhysPortID = NULL;
7548c0
     int ret = -1;
7548c0
     DIR *dir = NULL;
7548c0
     struct dirent *entry = NULL;
7548c0
@@ -2465,12 +2464,13 @@ virPCIGetNetName(const char *device_link_sysfs_path,
7548c0
          * physportID of this netdev. If not, look for entry[idx].
7548c0
          */
7548c0
         if (physPortID) {
7548c0
+            g_autofree char *thisPhysPortID = NULL;
7548c0
+
7548c0
             if (virNetDevGetPhysPortID(entry->d_name, &thisPhysPortID) < 0)
7548c0
                 goto cleanup;
7548c0
 
7548c0
             /* if this one doesn't match, keep looking */
7548c0
             if (STRNEQ_NULLABLE(physPortID, thisPhysPortID)) {
7548c0
-                VIR_FREE(thisPhysPortID);
7548c0
                 /* save the first entry we find to use as a failsafe
7548c0
                  * in case we don't match the phys_port_id. This is
7548c0
                  * needed because some NIC drivers (e.g. i40e)
7548c0
-- 
7548c0
2.30.0
7548c0