Skip to contentSkip to conversation

QEMU Guest Agent: Fix memory leak of device information set

PATCH Superseded Li Ping 2 participants 2 messages Jun 13, 2017

lore
Share & tools
lore

Li Ping

author
#0 lore raw

PATCH 1/1 QEMU Guest Agent: Fix memory leak of device information set

The caller of SetupDiGetClassDevs must delete the returned device information
set when it is no longer needed by calling SetupDiDestroyDeviceInfoList.

---
 qga/commands-win32.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
qga/commands-win32.c +4 -1
index 439d229..6f16457 100644
@@ -512,7 +512,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
             } else {
                 error_setg_win32(errp, GetLastError(),
                         "failed to get device name");
-                goto out;
+                goto free_dev_info;
             }
         }
 
@@ -560,6 +560,9 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
         pci->bus = bus;
         break;
     }
+
+free_dev_info:
+    SetupDiDestroyDeviceInfoList(dev_info);
 out:
     g_free(buffer);
     g_free(name);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Li Ping

The caller of SetupDiGetClassDevs must delete the returned device information
set when it is no longer needed by calling SetupDiDestroyDeviceInfoList.

Quoted 29 lines
---
 qga/commands-win32.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
qga/commands-win32.c +4 -1
index 439d229..6f16457 100644
@@ -512,7 +512,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error
 **errp)
             } else {
                 error_setg_win32(errp, GetLastError(),
                         "failed to get device name");
-                goto out;
+                goto free_dev_info;
             }
         }
@@ -560,6 +560,9 @@ static GuestPCIAddress *get_pci_info(char *guid, Error
 **errp)
         pci->bus = bus;
         break;
     }
+
+free_dev_info:
+    SetupDiDestroyDeviceInfoList(dev_info);
 out:
     g_free(buffer);
     g_free(name);
Quoted 6 lines

--
1.8.3.1

--

Marc-André Lureau