[Qemu-devel] [PATCH RESEND] QEMU Guest Agent: Fix memory leak of device information set

Li Ping posted 1 patch 8 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1498187863-4937-1-git-send-email-li.ping288@zte.com.cn
Test FreeBSD passed
Test checkpatch passed
Test docker passed
Test s390x passed
qga/commands-win32.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH RESEND] QEMU Guest Agent: Fix memory leak of device information set
Posted by Li Ping 8 years, 4 months ago
The caller of SetupDiGetClassDevs must delete the returned device information
 set when it is no longer needed by calling SetupDiDestroyDeviceInfoList.

Signed-off-by: Li Ping <li.ping288@zte.com.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qga/commands-win32.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 439d229..6f16457 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -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);
-- 
1.8.3.1



Re: [Qemu-devel] [PATCH RESEND] QEMU Guest Agent: Fix memory leak of device information set
Posted by Michael Tokarev 8 years, 4 months ago
23.06.2017 06:17, Li Ping wrote:
> The caller of SetupDiGetClassDevs must delete the returned device information
>  set when it is no longer needed by calling SetupDiDestroyDeviceInfoList.

Applied to -trivial, with s/QEMU Guest Agent/qga-win32/ in the Subject.

/mjt