[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 08/10] xencontrol: fix SetupDiDestroyDeviceInfoList never called in XcOpen


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: david ambu <david.preetham@xxxxxxxxxx>
  • Date: Thu, 8 Oct 2026 13:02:00 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From"
  • Cc: david ambu <david.preetham@xxxxxxxxxx>
  • Delivery-date: Thu, 08 Oct 2026 12:05:38 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

SetupDiGetClassDevs returns a device info set handle that must be
freed with SetupDiDestroyDeviceInfoList. On all failure paths between
SetupDiGetClassDevs and the end label the handle was leaked. Init
DevInfo to INVALID_HANDLE_VALUE and call SetupDiDestroyDeviceInfoList
at the end label when the handle is valid.

Signed-off-by: david ambu <david.preetham@xxxxxxxxxx>
Assisted by Claude Sonnet 4.6
---
 src/xencontrol/xencontrol.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/xencontrol/xencontrol.c b/src/xencontrol/xencontrol.c
index 1fdfd0b..a68dcf6 100644
--- a/src/xencontrol/xencontrol.c
+++ b/src/xencontrol/xencontrol.c
@@ -89,7 +89,7 @@ XcOpen(
     _Outptr_result_maybenull_ PXENCONTROL_CONTEXT   *Xc
     )
 {
-    HDEVINFO                                        DevInfo;
+    HDEVINFO                                        DevInfo = 
INVALID_HANDLE_VALUE;
     SP_DEVICE_INTERFACE_DATA                        InterfaceData;
     SP_DEVICE_INTERFACE_DETAIL_DATA                 *DetailData = NULL;
     DWORD                                           BufferSize;
@@ -168,6 +168,9 @@ XcOpen(
 end:
     free(DetailData);
 
+    if (DevInfo != INVALID_HANDLE_VALUE)
+        SetupDiDestroyDeviceInfoList(DevInfo);
+
     if (Status != ERROR_SUCCESS) {
         free(Context);
         *Xc = NULL;
-- 
2.51.0.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.