diff mbox series

[PULL,3/3] qemu-ga: Avoiding freeing line prematurely

Message ID 20241107104001.66039-4-kkostiuk@redhat.com (mailing list archive)
State New
Headers show
Series [PULL,1/3] qemu-ga: Add 'Null' check and Redefine 'route' | expand

Commit Message

Konstantin Kostiuk Nov. 7, 2024, 10:40 a.m. UTC
From: Dehan Meng <demeng@redhat.com>

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>
---
 qga/commands-linux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--
2.47.0
diff mbox series

Patch

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;
 }