qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Kostiuk <kkostiuk@redhat.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>
Subject: [PULL 3/3] qemu-ga: Avoiding freeing line prematurely
Date: Thu,  7 Nov 2024 12:40:01 +0200	[thread overview]
Message-ID: <20241107104001.66039-4-kkostiuk@redhat.com> (raw)
In-Reply-To: <20241107104001.66039-1-kkostiuk@redhat.com>

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(-)

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



  parent reply	other threads:[~2024-11-07 10:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 10:39 [PULL 0/3] QGA fixes for guest_network_get_route command for 9.2 Konstantin Kostiuk
2024-11-07 10:39 ` [PULL 1/3] qemu-ga: Add 'Null' check and Redefine 'route' Konstantin Kostiuk
2024-11-07 10:40 ` [PULL 2/3] qemu-ga: Optimize var declaration and definition Konstantin Kostiuk
2024-11-07 10:40 ` Konstantin Kostiuk [this message]
2024-11-08 10:22 ` [PULL 0/3] QGA fixes for guest_network_get_route command for 9.2 Peter Maydell
2024-11-08 11:29   ` Konstantin Kostiuk
2024-11-08 13:21     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241107104001.66039-4-kkostiuk@redhat.com \
    --to=kkostiuk@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).