Skip to contentSkip to conversation

hmp/vnc: Fix info vnc list leak

PATCH In review Dr. David Alan Gilbert (git) 2 participants 3 messages Mar 23, 2020 – Mar 24, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hmp/vnc: Fix info vnc list leak

From: "Dr. David Alan Gilbert" <[email protected]>

We're iterating the list, and then freeing the iteration pointer rather than the list head.

Fixes 0a9667ecdb6d ("hmp: Update info vnc")
Reported-by Coverity (CID 1421932)
---
 monitor/hmp-cmds.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
monitor/hmp-cmds.c +3 -2
index a00248527c..1d473e809c 100644
@@ -527,10 +527,11 @@ static void hmp_info_vnc_servers(Monitor *mon, VncServerInfo2List *server)
 
 void hmp_info_vnc(Monitor *mon, const QDict *qdict)
 {
-    VncInfo2List *info2l;
+    VncInfo2List *info2l, *info2l_head;
     Error *err = NULL;
 
     info2l = qmp_query_vnc_servers(&err);
+    info2l_head = info2l;
     if (err) {
         hmp_handle_error(mon, err);
         return;
@@ -559,7 +560,7 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict)
         info2l = info2l->next;
     }
 
-    qapi_free_VncInfo2List(info2l);
+    qapi_free_VncInfo2List(info2l_head);
 
 }
 #endif
Signature · 1 line
2.25.1
#2 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 8 lines · * Dr. David Alan Gilbert (git) ([email protected]) wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

We're iterating the list, and then freeing the iteration pointer rather than the list head.

Fixes 0a9667ecdb6d ("hmp: Update info vnc")
Reported-by Coverity (CID 1421932)

Queued

Quoted 34 lines
---
 monitor/hmp-cmds.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
monitor/hmp-cmds.c +3 -2
index a00248527c..1d473e809c 100644
@@ -527,10 +527,11 @@ static void hmp_info_vnc_servers(Monitor *mon, VncServerInfo2List *server)
 
 void hmp_info_vnc(Monitor *mon, const QDict *qdict)
 {
-    VncInfo2List *info2l;
+    VncInfo2List *info2l, *info2l_head;
     Error *err = NULL;
 
     info2l = qmp_query_vnc_servers(&err);
+    info2l_head = info2l;
     if (err) {
         hmp_handle_error(mon, err);
         return;
@@ -559,7 +560,7 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict)
         info2l = info2l->next;
     }
 
-    qapi_free_VncInfo2List(info2l);
+    qapi_free_VncInfo2List(info2l_head);
 
 }
 #endif
Signature · 1 line
2.25.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK