qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hyman Huang <yong.huang@smartx.com>
To: qemu-devel@nongnu.org
Cc: "alloc.young" <alloc.young@outlook.com>,
	Hyman Huang <yong.huang@smartx.com>
Subject: [PULL 1/3] softmmu: Fix dirtylimit memory leak
Date: Tue, 29 Aug 2023 23:29:48 +0800	[thread overview]
Message-ID: <ff118704fa5498c64a55d7a732fd42515fdc356c.1693322363.git.yong.huang@smartx.com> (raw)
In-Reply-To: <cover.1693322363.git.yong.huang@smartx.com>

From: "alloc.young" <alloc.young@outlook.com>

Fix memory leak in hmp_info_vcpu_dirty_limit,use g_autoptr
to handle memory deallocation.

Signed-off-by: alloc.young <alloc.young@outlook.com>
Reviewed-by: Hyman Huang <yong.huang@smartx.com>
Message-Id: <SA1PR11MB6760B9AB7EAFBDAFB524ED06F5E3A@SA1PR11MB6760.namprd11.prod.outlook.com>
Signed-off-by: Hyman Huang <yong.huang@smartx.com>
---
 softmmu/dirtylimit.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c
index 3c275ee55b..e3ff53b8fc 100644
--- a/softmmu/dirtylimit.c
+++ b/softmmu/dirtylimit.c
@@ -653,7 +653,8 @@ struct DirtyLimitInfoList *qmp_query_vcpu_dirty_limit(Error **errp)
 
 void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
 {
-    DirtyLimitInfoList *limit, *head, *info = NULL;
+    DirtyLimitInfoList *info;
+    g_autoptr(DirtyLimitInfoList) head = NULL;
     Error *err = NULL;
 
     if (!dirtylimit_in_service()) {
@@ -661,20 +662,17 @@ void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
         return;
     }
 
-    info = qmp_query_vcpu_dirty_limit(&err);
+    head = qmp_query_vcpu_dirty_limit(&err);
     if (err) {
         hmp_handle_error(mon, err);
         return;
     }
 
-    head = info;
-    for (limit = head; limit != NULL; limit = limit->next) {
+    for (info = head; info != NULL; info = info->next) {
         monitor_printf(mon, "vcpu[%"PRIi64"], limit rate %"PRIi64 " (MB/s),"
                             " current rate %"PRIi64 " (MB/s)\n",
-                            limit->value->cpu_index,
-                            limit->value->limit_rate,
-                            limit->value->current_rate);
+                            info->value->cpu_index,
+                            info->value->limit_rate,
+                            info->value->current_rate);
     }
-
-    g_free(info);
 }
-- 
2.39.1



  reply	other threads:[~2023-08-29 15:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 15:29 [PULL 0/3] Dirty page rate and dirty page limit 20230829 patches Hyman Huang
2023-08-29 15:29 ` Hyman Huang [this message]
2023-08-30 16:55   ` [PULL 1/3] softmmu: Fix dirtylimit memory leak Michael Tokarev
2023-08-31  1:01     ` Yong Huang
2023-08-29 15:29 ` [PULL 2/3] softmmu/dirtylimit: Convert free to g_free Hyman Huang
2023-08-29 15:29 ` [PULL 3/3] migration/dirtyrate: Fix precision losses and g_usleep overshoot Hyman Huang
2023-08-30 16:22 ` [PULL 0/3] Dirty page rate and dirty page limit 20230829 patches Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2023-08-28 17:19 Hyman Huang
2023-08-28 17:19 ` [PULL 1/3] softmmu: Fix dirtylimit memory leak Hyman Huang
2023-08-28 17:32   ` Hyman Huang

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=ff118704fa5498c64a55d7a732fd42515fdc356c.1693322363.git.yong.huang@smartx.com \
    --to=yong.huang@smartx.com \
    --cc=alloc.young@outlook.com \
    --cc=qemu-devel@nongnu.org \
    /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).