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