summary refs log tree commit diff stats
path: root/qga/commands-linux.c
diff options
context:
space:
mode:
authorDehan Meng <demeng@redhat.com>2024-11-07 12:21:55 +0200
committerKonstantin Kostiuk <kkostiuk@redhat.com>2024-11-07 12:28:20 +0200
commit5ab1c032e6eea810142eb918c57222464482756f (patch)
tree4477aee687a73383dab1d5212ff97267065e17f2 /qga/commands-linux.c
parentccc2dfab57bfe4fdd02288761a7e7482f352bfcc (diff)
downloadfocaccia-qemu-5ab1c032e6eea810142eb918c57222464482756f.tar.gz
focaccia-qemu-5ab1c032e6eea810142eb918c57222464482756f.zip
qemu-ga: Avoiding freeing line prematurely
It's now only freed at the end of the function.

Signed-off-by: Dehan Meng <demeng@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Message-ID: <20241107102155.57573-4-kkostiuk@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Diffstat (limited to 'qga/commands-linux.c')
-rw-r--r--qga/commands-linux.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/qga/commands-linux.c b/qga/commands-linux.c
index b0704ad423..cf077eb03d 100644
--- a/qga/commands-linux.c
+++ b/qga/commands-linux.c
@@ -2138,7 +2138,6 @@ GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp)
         fp = fopen(route_files[i], "r");
         if (fp == NULL) {
             error_setg_errno(errp, errno, "open(\"%s\")", route_files[i]);
-            free(line);
             continue;
         }
 
@@ -2212,9 +2211,9 @@ GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp)
             route = NULL;
         }
 
-        free(line);
         fclose(fp);
     }
 
+    free(line);
     return head;
 }