On a Monday in 2020, Ryan Gahagan wrote:
From: Barrett Schonefeld <bscho...@utexas.edu>

- src/util/virscsihost.c

Signed-off-by: Barrett Schonefeld <bscho...@utexas.edu>
---
src/util/virscsihost.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c
index 969cdd9f79..2ce33e4cfb 100644
--- a/src/util/virscsihost.c
+++ b/src/util/virscsihost.c
@@ -95,12 +95,12 @@ virSCSIHostFindByPCI(const char *sysfs_prefix,
    const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_HOST_PATH;
    struct dirent *entry = NULL;
    g_autoptr(DIR) dir = NULL;
-    char *host_link = NULL;
-    char *host_path = NULL;
+    g_autofree char *host_link = NULL;
+    g_autofree char *host_path = NULL;
    char *p = NULL;
    char *ret = NULL;
-    char *buf = NULL;
-    char *unique_path = NULL;
+    g_autofree char *buf = NULL;
+    g_autofree char *unique_path = NULL;
    unsigned int read_unique_id;

    if (virDirOpen(&dir, prefix) < 0)
@@ -151,10 +151,6 @@ virSCSIHostFindByPCI(const char *sysfs_prefix,
    }

 cleanup:
-    VIR_FREE(unique_path);
-    VIR_FREE(host_link);
-    VIR_FREE(host_path);
-    VIR_FREE(buf);

All of these are also freed in the loop.

Jano

    return ret;
}

Attachment: signature.asc
Description: PGP signature

Reply via email to