render / rpms / libvirt

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